centos 源码安装最新Git

1. 安装依赖包

Git 的工作需要调用 curl,zlib,openssl,expat,libiconv 等库的代码,所以需要先安装这些依赖工具。在有 yum 的系统上(比如 Fedora)或者有 apt-get 的系统上(比如 Debian 体系),可以用下面的命令安装:

 yum install curl-devel expat-devel gettext-devel  openssl-devel zlib-devel

2. 下载&解压

建议下载地址:https://mirrors.edge.kernel.org/pub/software/scm/git/

wget https://www.kernel.org/pub/software/scm/git/git-2.21.0.tar.gz
tar -zxvf git-2.21.0.tar.gz
cd git-2.21.0

3. 编译安装

cd git-2.21.0
./configure --with-openssl=/usr/local/openssl
make prefix=/usr/local/git all
make prefix=/usr/local/git install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc

4.检查git版本

git --version
# git version 2.21.0

5. bug: 在make这一步出错,错误代码:

imap-send.o: In function `sk_GENERAL_NAME_num':
/usr/local/include/openssl/x509v3.h:165: undefined reference to `OPENSSL_sk_num'
imap-send.o: In function `sk_GENERAL_NAME_value':
/usr/local/include/openssl/x509v3.h:165: undefined reference to `OPENSSL_sk_value'
imap-send.o: In function `sk_GENERAL_NAME_pop_free':
/usr/local/include/openssl/x509v3.h:165: undefined reference to `OPENSSL_sk_pop_free'
/usr/local/include/openssl/x509v3.h:165: undefined reference to `OPENSSL_sk_pop_free'
imap-send.o: In function `ssl_socket_connect':
/usr/local/src/git-2.11.1/imap-send.c:287: undefined reference to `OPENSSL_init_ssl'
/usr/local/src/git-2.11.1/imap-send.c:288: undefined reference to `OPENSSL_init_ssl'
/usr/local/src/git-2.11.1/imap-send.c:290: undefined reference to `TLS_method'
/usr/local/src/git-2.11.1/imap-send.c:303: undefined reference to `SSL_CTX_set_options'
collect2: error: ld returned 1 exit status
make: *** [git-imap-send] Error 1

openssl问题,自带的是OpenSSL 1.0.1e-fips 11 Feb 2013,把它升级到了openssl-1.1.0d。从新编译安装

你可能感兴趣的:(运维)