如何在最小化安裝的CentOS 7.5上編譯安裝Git2.19

VMware Workstation已經採用最小化安裝CentOS7,顯示版本爲CentOS7.5,準備採用yum安裝git。採用yum list git發現可安裝的GIT軟件包版本1.8.3.1,新的版本已經是2.19了,因此,我決定編譯安裝git2.19。

如何在最小化安裝的CentOS 7.5上編譯安裝Git2.19如何在最小化安裝的CentOS 7.5上編譯安裝Git2.19

由於採用最小化安裝系統,編譯時出現一些問題,這裏對處理過程作一下備忘:

1、首先在git官網上下載最新的版本,下載地址:https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.19.0.tar.gz

2、由於採用win10操作系統下載的文件,需要上傳到CentOS7上,操作方式我一般通過SecureCRT採用SSH2協議登錄,

上傳文件也通過SecureCRT工具中的SFTP協議,具體方法如圖:

如何在最小化安裝的CentOS 7.5上編譯安裝Git2.19如何在最小化安裝的CentOS 7.5上編譯安裝Git2.19

注意:上傳的文件會在登錄用戶的home目錄下,可以通過lpwd查看本地目錄,pwd查看遠端目錄

3、對文件解壓:tar xzvf git-2.19.0.tar.gz

4、進入解壓後的git目錄後,安裝方式參考:https://github.com/git/git/blob/master/INSTALL或目錄下的INSTALL,這裏採用建議步驟:

如何在最小化安裝的CentOS 7.5上編譯安裝Git2.19如何在最小化安裝的CentOS 7.5上編譯安裝Git2.19

# make configure ;# as yourself
# ./configure --prefix=/usr ;# as yourself
# make all doc ;# as yourself
# make install install-doc install-html;# as root

5、首先執行make configure,開始就出錯了,提示:

configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/opt/git-2.19.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

通過yum provides gcc和 yum provides cc查詢到c編譯器沒有安裝,yum -y install gcc安裝gcc包及對應的依賴。

6、再次執行make configure,再次出現如下錯誤:

GIT_VERSION = 2.19.0
 GEN configure
/bin/sh: autoconf: 未找到命令
make: *** [configure] 錯誤 127

通過yum provides autoconf查詢到沒有安裝autoconf,yum -y install autoconf安裝包及對應的依賴。

7、再一次執行make configure,正常了,接下來 ./configure很順利。

8、執行make all doc,又出現錯誤:

* new build flags
 CC credential-store.o
In file included from credential-store.c:1:0:
cache.h:20:18: 致命錯誤:zlib.h:沒有那個文件或目錄
#include 
 ^
編譯中斷。
make: *** [credential-store.o] 錯誤 1

錯誤指出沒有zlib,yum -y install zlib安裝,發現已經安裝,zlib.h應該是對應的開發包沒有,yum -y install zlib-devel安裝開發包

9、再執行make all doc,再出現錯誤:

/bin/sh:行1: asciidoc: 未找到命令
make[1]: *** [git-init-db.html] 錯誤 127
make[1]: 離開目錄“/opt/git-2.19.0/Documentation”
make: *** [doc] 錯誤 2

沒有asciidoc命令,yum list asciidoc發現包沒有安裝,yum -y install asciidoc安裝該包。

10、再一次執行make all doc,仍出現錯誤:

/bin/sh:行1: xmlto: 未找到命令
make[1]: *** [git-init-db.1] 錯誤 127
make[1]: 離開目錄“/opt/git-2.19.0/Documentation”
make: *** [doc] 錯誤 2

思路一樣,沒有xmlto命令,yum list xmlto發現包沒有安裝, yum -y install xmlto安裝該包,執行make all doc這下很順利。

11、執行make install install-doc install-html,這下安裝很順利,沒有再提示錯誤。

12、測試一下,執行git --version正常顯示:

git version 2.19.0

終於安裝成功了,可以正常使用。

本文地址:https://www.linuxprobe.com/centos-setup-git.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章