centos7更换阿里云的源

一、一键清空旧源 + 换阿里云 CentOS 7 源

直接复制执行:
 
# 1. 进入源目录
cd /etc/yum.repos.d/

# 2. 备份旧源(自动创建备份文件夹)
mkdir -p backup
mv *.repo backup/

# 3. 下载阿里云 CentOS 7 官方源
curl -o CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

# 4. 下载阿里云 EPEL 源
curl -o epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

# 5. 清理缓存并生成新缓存
yum clean all
yum makecache

二、测试是否成功

 
yum repolist
不出错 = 换源成功。
 

三、如果还是报错(404、无法连接)

执行这个修复版(CentOS 7 已停止维护,必须用 vault 源):
 
cd /etc/yum.repos.d/
mkdir -p backup
mv *.repo backup/

curl -o CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-7.repo
curl -o epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

yum clean all
yum makecache

已有 0 条评论

    欢迎您,新朋友,感谢参与互动!