centos7源码安装github

当前时间:2019年3月3日

资源:

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

环境准备:

[root@sonny ~]# 
yum install curl-devel expat-devel gettext-devel 
openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
[root@sonny ~]# mkdir /root/git  # github安装位置

安装:

# 当前目录/opt/download,git-2.8.6.tar.gz安装包已经在该目录
[root@sonny ~]# tar zxvf git-2.8.6.tar.gz
[root@sonny ~]# ./configure --prefix=/root/git
[root@sonny ~]# make && make install

备注:
centos6需要更新openssl,加载configure文件需要使用 --with-openssl=/usr/local/openssl
https://blog.51cto.com/13544424/2149473

设置环境变量:

[root@sonny ~]# touch /etc/profile.d/git.sh
[root@sonny ~]# echo "export PATH=$PATH:/root/git/bin" >> /etc/profile.d/git.sh
[root@sonny ~]# source /etc/profile

测试:

[root@sonny ~]# git --version

使用shell脚本安装:

  • 在centos里下载安装包
yum install -y wget
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.8.6.tar.gz

编写git.sh文件,将以下内容粘贴进去,然后让脚本具有执行权限:chmod +x ./git.sh
git按转包和git.sh要在/opt/download目录里
执行脚本:source git.sh

!/bin/bash
# 当前目录/opt/download,且安装包已经下载
yum install -y curl-devel expat-devel gettext-devel 
openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
mkdir /usr/local/git

# 安装
tar zxvf git-2.8.6.tar.gz
cd git-2.8.6
./configure --prefix=/usr/local/git
make && make install

# 设置环境变量
touch /etc/profile.d/git.sh
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile.d/git.sh
source /etc/profile

# 测试
git --version
Hole yor life get everything if you never give up.
原文地址:https://www.cnblogs.com/1fengchen1/p/13998062.html