标签:
yum源中安装的git版本是1.7.1,太老了,Github等需要的Git版本最低都不能低于1.7.2 。所以我们一般不用上面的方法。而是下载git源码,编译安装:
Git 的工作需要调用 curl,zlib,openssl,expat,libiconv 等库的代码,所以需要先安装这些依赖工具
[root@GIT ~]# yum install curl-devel expat-devel gettext-devel > openssl-devel zlib-devel -y
https://github.com/git/git/releases#下载最新的包
[root@GIT git-2.9.2]# mkdir -p /app/servers [root@GIT src]# wget https://github.com/git/git/archive/v2.9.2.tar.gz [root@GIT src]# ll -h v2.9.2.tar.gz -rw-r--r--. 1 root root 5.7M Aug 2 05:32 v2.9.2.tar.gz [root@GIT src]# tar -xzvf v2.9.2.tar.gz [root@GIT src]# cd git-2.9.2/ [root@GIT git-2.9.2]# pwd /usr/local/src/git-2.9.2 [root@GIT git-2.9.2]# make prefix=/app/servers/git-2.9.2 all
有报错:
/usr/bin/perl Makefile.PL PREFIX=‘/app/servers/git-2.9.2‘ INSTALL_BASE=‘‘ --localedir=‘/app/servers/git-2.9.2/share/locale‘ 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. make[1]: *** [perl.mak] Error 2 make: *** [perl/perl.mak] Error 2
[root@GIT git-2.9.2]# yum install perl-ExtUtils-MakeMaker package -y
问题解决!!!
[root@GIT git-2.9.2]# make prefix=/app/servers/git-2.9.2 install
改变环境变量:在/etc/profile 最后一行加上“export PATH=$PATH:/app/servers/git/bin”
[root@GIT git]# tail -1 /etc/profile export PATH=$PATH:/app/servers/git/bin [root@GIT git]# source /etc/profile [root@GIT git]# git --version git version 2.9.2
标签:
原文地址:http://www.cnblogs.com/bass6/p/5746424.html