作环境:在VMware下安装的CentOS 7
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
1、删除自带的YUM源仓库
[root@localhost ~]# rm -rf /etc/yum.repos.d/*
2、搜索阿里云开源镜像站,选择相应的系统,复制下载链接
3、下载阿里云YUM源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
4、重新建立缓存
[root@localhost ~]# yum clean all //清理所有缓存数据
[root@localhost ~]# yum makecache fast //重新建立元数据缓存
5、验证
[root@localhost ~]# yum repolist //列出YUM源仓库
[root@localhost ~]# yum install -y httpd //安装apache服务