在CentOS上安裝Git

來源:互聯網
上載者:User

CentOS 5的yum源中沒有git,只能自己編譯安裝,現記錄下編譯安裝的內容及錯誤解決方案,留給自己備忘。
編譯基礎環境環境

1 yum -y installgccmake

 
確保已安裝了依賴的包

1 yum install-y curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel

 
下載最新的git包

1 wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
2 tar xzvf git-latest.tar.gz
3 cd git-2012-07-05 #你的目錄可能不是這個
4 autoconf
5 ./configure
6 make && make install

 
檢查下安裝的版本,大功告成

1 [root@cobbler git-2012-07-05]# git --version
2 git version 1.7.11.GIT

 
 
編譯時間遇到錯誤訊息及解決方案:

make[1]: Warning: File `Makefile' has modification time 3e+06 s in the future/usr/bin/perl Makefile.PL PREFIX='/usr/local' INSTALL_BASE='' --localedir='/usr/local/share/locale'Writing perl.mak for Gitmake[1]: warning:  Clock skew detected.  Your build may be incomplete.    GEN git-add--interactivemake[1]: Warning: File `Makefile' has modification time 3e+06 s in the futureWriting perl.mak for Gitmake[2]: Warning: File `Makefile.PL' has modification time 3e+06 s in the futureUse of uninitialized value $localedir in concatenation (.) or string at Makefile.PL line 52.Writing perl.mak for Gitmake[2]: *** [perl.mak] Error 1make[1]: *** [instlibdir] Error 2make: *** [git-add--interactive] Error 2在網上搜尋了一些,根據出錯的warning發現是機器時間設定的問題。。是機器系統的時間比版本的時間早。所以要系統時間重新設定。

 
 
由於CentOS6中yum源中已經有git的版本了,可以直接使用yum源進行安裝

1 yum -y installgit
2  
3 目前yum源中的git版本如下
4 [root@cobbler ~]# git --version
有可能會報錯:git: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory

解決方案如下:
不久前升級了iconv庫影響。在/usr/local/lib下可以找到libiconv.so.2,把/usr/local/lib加到路徑中也不行。

方法一:

在/etc/ld.so.conf中加一行/usr/local/lib,運行ldconfig。再運行apache,OK。
ld.so.conf和ldconfig是維護系統動態連結程式庫的。真不明白為什麼iconv庫安裝時不把這一步也做了

方法二:

ln -sf /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2


CENTOS 下 編譯安裝 git

1.先給大家說下編譯安裝方法,安裝前準備
yum -y install zlib-devel openssl-devel perl cpio expat-devel gettext-devel openssl zlib curl autoconf tk
wget http://git-core.googlecode.com/files/git-1.7.10.tar.gz

2.安裝git
tar zxf git-latest.tar.gz
cd git-{date} 我這裡是git-2012-04-17的版本,所以我的命令是cd git-2012-04-17/
autoconf
./configure
make
make install
make和make install在這裡最好分開執行,免得有錯不知道.
git --version
git version 1.7.10

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.