環境:Centos七、JDK1.8(已經安裝成功)、MySQL5.7(已經安裝成功)、Git 步驟: 1.下載Git源碼 2.移除舊版本 3.安裝&配置
手動下載下來在上傳到服務器上面,固然也能夠經過wget直接下載到服務器上。這裏使用wget直接下載git到服務器上。html
Centos7自帶git x.x.x.x版本,安裝新版本以前須要使用yum remove git卸載(安裝後卸載也能夠)。github
#可能輸入git --version顯示'bash: git: 未找到命令...' 則接着往下執行便可bash [root@Git ~]# git --version ## 查看自帶的版本服務器 git version 1.8.3.1curl [root@Git ~]# yum remove git ## 移除原來的版本url |
(1).安裝依賴包spa
安裝依賴包的時候首先須要配置yum源,若是配置了則請忽略。http://www.javashuo.com/article/p-qtagpdyn-nv.htmlhtm
[root@Git ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel -y [root@Git ~]# yum install gcc-c++ perl-ExtUtils-MakeMaker -y |
(2).下載&解壓
#進入到src中,把git源碼包下載到該地方 [root@Git src]# cd /usr/src
#經過wget下載git-2.7.3版本源碼,若wget不存在,則經過yum install wget安裝wget [root@Git src]# wget https://www.kernel.org/pub/software/scm/git/git-2.7.3.tar.gz
#解壓下載源碼包 [root@Git src]# tar -zxvf git-2.7.3.tar.gz |
(3).編譯安裝
#進入解壓的git目錄 [root@Git src]# cd git-2.7.3
#若出現錯誤,接着往下看 執行yum install autoconf -y [root@Git src]# make configure
[root@Git src]# ./configure --prefix=/usr/git ##配置目錄
[root@Git src]# make profix=/usr/git
[root@Git src]# make install |
問題:'make configure'出現錯誤'/bin/sh:autoconf:未找到命令'
解決方法:
執行'yum install autoconf -y'.
[root@Git src]# yum install autoconf -y |
(4).環境變量
[root@Git ~]# echo "export PATH=$PATH:/usr/git/bin" >> /etc/profile [root@Git ~]# source /etc/profile |
(5).檢查版本
#若顯示git version 1.8.3.1,則未remove成功。接着往下看解決方法 [root@Git git-2.7.3]# git --version git version 2.7.3 |
問題:輸入'git --verison'若顯示git version 1.8.3.1,則未remove成功.只須要從新執行如下便可。
[root@localhost git-2.7.3]# yum remove git [root@localhost git-2.7.3]# echo "export PATH=$PATH:/usr/git/bin" >> /etc/profile [root@localhost git-2.7.3]# source /etc/profile [root@localhost git-2.7.3]# git --version git version 2.7.3 |