返回博客

CentOS 7 Yum 源更改教程

本文介绍如何更改 CentOS 7 的 Yum 源,包括备份原有源、使用阿里云和网易源,以及安装 EPEL 源的方法,并提供其他 CentOS 版本换源的命令。文章涵盖了备份现有 yum 源,使用阿里云和网易源,安装 EPEL 源以及其他 CentOS 版本换源命令等内容。

Mt.r
|

解决

进入目录,备份

cd /etc/yum.repos.d/
mkdir repo_bak
mv *.repo repo_bak/

换源

wget http://mirrors.aliyun.com/repo/Centos-7.repo
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

除系统 yum 缓存并生成新的 yum 缓存

yum clean all		# 清除系统所有的 yum 缓存
yum makecache		# 生成 yum 缓存

安装 epel 源

yum list | grep epel-release
yum install -y epel-release

使用阿里开源镜像提供的 epel 源

wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all		# 清除系统所有的 yum 缓存
yum makecache		# 生成 yum 缓存

其他

CentOS 8

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

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

CentOS 7

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

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

CentOS 6

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

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo

参考文章