Vm ware虚拟机下新建的centOS7系统,不能yum install,如下图:
原因是因为国外镜像源访问不了,需要更换为国内的镜像源,主要有两种:
1.阿里镜像源:https://mirrors.aliyun.com/repo/Centos-7.repo
2.网易镜像源:https://mirrors.163.com/repo/Centos-7.repo
我这里用的阿里的源
一、首先备份当前的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 https://mirrors.aliyun.com/repo/Centos-7.repo
三、清除一下yum缓存
yum clear all
四、重新生成缓存
yum makecache
五、重新运行 yum install 命令,搞定
注:如果不是root权限,命令前面需要加 sudo