在Linux系统(CentOS7)上安装Git

本文详细介绍在CentOS7上配置阿里云的yum源和epel源的方法,以及从源码编译安装Git的全过程。包括下载阿里云的yum源和epel源,清除缓存,以及安装Git所需的编译环境,下载源码,编译和安装Git。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、在CentOS7上配置yum源与epel源

centos7配置aliyun的yum源和epel源
centos7配置阿里云yum源:
1、切换到/etc/yum.repos.d/目录下

   cd /etc/yum.repos.d

2、将CentOS-Base.repo 改为CentOS-Base.repo.backup

   mv CentOS-Base.repo CentOS-Base.repo.backup

3、下载阿里云yum源到/etc/yum.repos.d/目录下

   wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

centos7配置阿里云epel源:
1、切换到/etc/yum.repos.d/目录下

  cd /etc/yum.repos.d 

2、下载epel源

   wget https://mirrors.aliyun.com/repo/epel-7.repo
   wget http://mirrors.aliyun.com/repo/epel-6.repo

[ps: yum -y install epel-release也是安装的阿里云的epel源]
清楚缓存:

 yum clean all && yum makecache 

【上面的yum源和epel源,如果只安装一个,在每一个结束时都要清楚缓存 yum clean all && yum makecache】

二、在CentOS7上安装Git

centos7安装git过程
1、删除已存在git

   yum remove git

2、安装编译环境

#安装gcc
yum install gcc
#安装g++
yum install gcc-c++
#安装其它所需的包
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker

3、下载源码

   wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz

4、进入指定目录

   cd /root/

5、解压文件

   tar zxvf git-2.9.5.tar.gz

6、进入解压目录

    cd git-2.9.5/

7、配置安装目录并且编译和安装

   ./configure --prefix=/root/git-2.9.5 && make && make install

8、将编译好的git添加到全局变量

   vim /etc/profile
   
   #git 添加到文件最后
   export PATH="$PATH:/root/git-2.9.5/bin"
   #保存
   :wq

9、立即生效配置的变量

   source /etc/profile

10、查看版本

    git --version
此博客转载自:centos7配置aliyun的yum源和epel源;centos7安装git过程
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值