CentOS 5的yum源中沒有git,只能自己編譯安裝,現記錄下編譯安裝的內容及錯誤解決方案,留給自己備忘。
編譯基礎環境環境
確保已安裝了依賴的包
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 #你的目錄可能不是這個 |
檢查下安裝的版本,大功告成
1 |
[root@cobbler git-2012-07-05]# git --version |
編譯時間遇到錯誤訊息及解決方案:
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源進行安裝
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