centos7换yum源

centos换源yum包

删除默认的 repo 文件
sudo rm -rf /etc/yum.repos.d/*

下载阿里云的镜像文件
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

备用1:清华的镜像
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/repodata/repomd.xml

备用2:华为云的镜像
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo

sudo yum clean all # 清除缓存
sudo yum makecache # 生成新缓存
sudo yum update # 更新软件包

安装 EPEL 额外软件源
sudo yum install epel-release
然后可以替换 EPEL 的国内源 阿里云
sudo curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

posted @ 2025-04-29 13:03  95158  阅读(128)  评论(0)    收藏  举报