CentOS搭建yum源及EPEL仓库

一、CentOS搭建yum源

1、备份配置文件

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5

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

或者

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

CentOS 6

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

或者

curl -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

或者

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

点解这里查看更多-->https://opsx.alibaba.com/mirror

3、之后运行yum makecache生成缓存

yum makecache

二、搭建EPEL仓库

1、在CentOS6和CentOS7都可以执行下面的命令安装epel仓库

yum -y install epel-release

2、 移除epel仓库

在CentOS6和CentOS7都可以执行下面的命令移除epel仓库

yum -y remove epel-release

3 、查看仓库信息

yum repolist