将CentOS默认的yum源更换为国内的阿里源

1. 备份默认的源文件,防止因更换失败而出现的错误

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2.下载新的CentOS-Base.repo到/etc/yum.repos.d/(也可以先现在好一个,然后在上传到服务器)

(1) CentOS 5阿里源

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

(2) CentOS 6阿里源

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

(3) CentOS 7阿里源

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

3. 之后运行yum makecache生成缓存

猜你喜欢

转载自www.cnblogs.com/mousecode/p/12497643.html