centos最新的7.2版本,git居然是1.8,而最新的git版本是2.9
差的太多了,何況git2.0后有大更新。於是,我決定編譯安裝。中間有一點小破折,記錄一下,備忘。
1,下載最新的源碼,網址:https://www.kernel.org/pub/software/scm/git/
我下載的地址:https://www.kernel.org/pub/software/scm/git/git-2.9.2.tar.gz
2,解壓:tar xzvf git-2.9.2.tar.gz
3,進入解壓后的git目錄后,執行:./configure很順利。
4,make的時候出錯了。提示如下:
In file included from credential-store.c:1:
cache.h:21:18: warning: zlib.h: No such file or directory
In file included from credential-store.c:1:
cache.h:23: error: expected specifier-qualifier-list before ‘z_stream’
make: *** [credential-store.o] Error 1
=============
缺少 zlib的頭文件, 開發包沒裝,
yum install zlib (系統默認已經裝上)
yum install zlib-devel
5,make install時,有出現一個錯誤。提示如下:
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5
/usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl
/usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.
=========================
原來一個perl的模塊需要安裝:perl-ExtUtils-Embed
yum install perl-ExtUtils-Embed -y
6,經過以上的波折,終於make install成功。但是運行git的時,又提示:
/usr/bin/git 沒有哪個文件或目錄
=================================
原來git安裝到/usr/local/bin/目錄內了,而centos默認該目錄沒有在搜索目錄內。
解決辦法,建立一個軟鏈接吧。
ln -s /usr/local/bin/git /usr/bin/git
大功告成。