在CentOS 7中更换阿里(li)YUM源,更换可(ke)以提高软件包的阿里下载速度,同时也可以避免一些国外源的更(geng)换软件包在(zai)国内访问不稳定的问题,下面将详细介绍如何在CentOS 7中更换阿里YUM源。阿里
1. 首先(xian)备份原有的更换YUM源配置文件(jian):


sudo cp -r /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. 下载阿里云的YUM源配置文件(jian):

sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3. 清除YUM缓存:
sudo yum clean all
4. 生成YUM缓存:
sudo yum makecache
阿里(li)云YUM源已(yi)经替换为CentOS 7的默认源,接下来可以(yi)通过以下命令查看当前使用的阿里YUM源:
cat /etc/yum.repos.d/CentOS-Base.repo
如果显示的是阿里云的YUM源地址,说(shuo)明切换成功。更换
相关问题与解(jie)答:
Q1: 如何修改其他软件包的阿里(li)管理器?
A1: 如果(guo)需要修改(gai)其(qi)他软件包的(de)管理(li)器,可以(yi)在安装时指(zhi)定使用其他源,更换安装Nginx时可(ke)以使用以下命令:
阿里(li)sudo yum install -y epel-release http://mirrors.aliyun.com/epel/7/noarch/nginx-1.16.1-1.el7.ngx.x86_64.rpm http://mirrors.aliyun.com/epel/7/noarch/nginx-1.16.1-1.el7.ngx.i686.rpm