源码安装git

1、安装依赖包

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

2、下载git源码并解压缩

wget https://www.kernel.org/pub/software/scm/git/git-2.9.3.tar.gz

tar -xvf git-2.9.3.tar.gz

cd git-2.9.3

3、编译安装

./configure prefix=/usr/local/git

make

make install

4、填加环境变量

vim /etc/profile

export PATH=$PATH:/usr/local/git/bin

5、验证安装是否成功

source /etc/profile

git --version

6、如果出现报错

git: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory

先执行ldd /usr/local/git/bin/git看下需要有哪些库

ldd /usr/local/git/bin/git
        linux-vdso.so.1 =>  (0x00007fffcdf96000)
        libz.so.1 => /lib64/libz.so.1 (0x0000003beea00000)
        libiconv.so.2 => not found
        libcrypto.so.6 => /lib64/libcrypto.so.6 (0x00002b4ec5152000)
        libcharset.so.1 => not found
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003361400000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003360c00000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000003361000000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003360800000)

执行软连接

ln -s /usr/local/lib/libiconv.so.2 /lib64/libiconv.so.2

ln -s /usr/local/lib/libcharset.so.1 /lib64/libcharset.so.1

转载于:https://www.cnblogs.com/wuxie1989/p/5830256.html

你可能感兴趣的:(源码安装git)