Linux CentOS 6/7 一键更换为阿里yum源

文字出处:港云网络  |  责任编辑:港云网络  |  发布时间:2019-11-14 14:55:03

虽然不是什么难事,既然用到了就记录一下吧!


阿里官方镜像源:https://developer.aliyun.com/mirror/


知道你们懒直接上一键脚本

 

「CentOS 6」


yum install -y wget;cd /etc/yum.repos.d/;mv CentOS-Base.repo CentOS-Base.repo.bak;wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo;yum clean all;yum makecache


「CentOS 7」

yum install -y wget;cd /etc/yum.repos.d/;mv CentOS-Base.repo CentOS-Base.repo.bak;wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo;yum clean all;yum makecache


1、安装wget


yum install -y wget


不想安装 wget 的话可以尝试一下 curl


2、备份 CentOS-Base.repo 防止翻车


cd /etc/yum.repos.d/


mv CentOS-Base.repo CentOS-Base.repo.bak


3、下载 CentOS-Base.repo 文件,根据自己是 CentOS 6 还是 7 更改下述加粗内容


「CentOS 6」


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


「CentOS 7」


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


如果 wget 的时候出现了问题(比如说DNS设置错误等疑难杂症)

可以尝试一下手动下载 repo 文件,然后用 FileZilla 上传。 

这条帮助是否解决了您的问题? 已解决 未解决