4
0

Centos 7.9 配置阿里云镜像源

2026-05-06
2026-05-06

备份

sudo mkdir -p /etc/yum.repos.d/backup
sudo cp /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/ 2>/dev/null || echo 「无旧配置文件」

方法一:使用 wget

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

方法二:使用 curl

sudo curl -o /etc/yum.repos.d/CentOS-Base.repo HTTPS://mirrors.aliyun.com/repo/Centos-7.repo

若提示 curl: command not found,可先使用系统最小化安装自带的 yum 安装:
yum install -y curl

清理并重建 YUM 缓存

# 清理旧缓存
sudo yum clean all

# 生成新缓存(推荐使用 makecache fast 提升速度)
sudo yum makecache fast

验证源是否生效

# 查看已启用的仓库
sudo yum repolist

输出中应包含类似以下内容,确认 mirrors.aliyun.com 出现在仓库地址中:

repo id                      repo name
base/7/x86_64                CentOS-7 - Base - mirrors.aliyun.com
updates/7/x86_64             CentOS-7 - Updates - mirrors.aliyun.com
epel/x86_64                  Extra Packages for Enterprise Linux 7 - mirrors.aliyun.com

更新系统(可选)

# 更新所有已安装的软件包
sudo yum update -y

Centos 7.9 配置阿里云镜像源
/archives/centos-aliyun-yum
Author
Administrator
Published at
2026-05-06
License
CC BY-NC-SA 4.0

Comments