Linux编译构建git之用于内网环境
通常安装git的时候直接yum -y install git
就安装好了,但是某些时候公司服务器是不连外网的,只能先找台有网的机器编译好,然后将构建包传到内网机器上。
git源码包下载地址1:https://mirrors.edge.kernel.org/pub/software/scm/git/
git源码包下载地址2:https://github.com/wl4g-collect/git-2.27.0
git二进制包下载地址1(已编译好):https://gitee.com/wl4g-collect/git-2.27.0/releases/2.27.0
git二进制包下载地址2(已编译好):https://github.com/wl4g-collect/git-2.27.0/releases/tag/2.27.0
1. 首先找台联网机构建离线包
例如我的编译主机是 CentOS 7
[root@owner1 ~]# tar -xvf git-2.27.0.tar.gz
[root@owner1 ~]# cd git.2.27.0
[root@owner1 git.2.27.0]# sudo mkdir -p /usr/local/git-2.27.0
[root@owner1 git.2.27.0]# sudo ./configure --prefix=/usr/local/git-2.27.0
[root@owner1 git.2.27.0]# sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
[root@owner1 git.2.27.0]# sudo make && make install
2. 再将离线包传过去
[root@owner1 git.2.27.0]# cd /usr/local/
[root@owner1 local]# sudo tar -zcf git-2.27.0-centos7-x64-bin.tar.gz git-2.27.0
[root@owner1 local]# scp git-2.27.0-centos7-x64-bin.tar.gz root@47.x.x.202:/usr/local/
[root@owner1 local]# ssh root@47.x.x.202
[root@owner1 ~]# cd /usr/local/
[root@owner1 local]# sudo tar -zxf git-2.27.0-centos7-x64-bin.tar.gz
[root@owner1 local]# sudo echo 'export GIT_HOME=/usr/local/git-2.27.0' >>/etc/bashrc
[root@owner1 local]# sudo echo 'export PATH=$PATH:$GIT_HOME/bin:' >>/etc/bashrc
[root@owner1 local]# . /etc/bashrc
[root@owner1 local]# git --version
git version 2.27.0