Cannot find a valid baseurl for repo: base/7/x86_64 解决办法
一、检查网络连接
确保你的服务器可以访问互联网。你可以使用 ping 命令来测试:
ping www.baidu.com
若能访问外网,则网络没问题,否则检查网络
二、修改CentOS-Base.repo文件
执行:sudo vi /etc/yum.repos.d/CentOS-Base.repo
将文件内容修改为
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=centos安装包下载_开源镜像站-阿里云http://mirrors.aliyun.com/centos/$releasever/os/$basearch/centos安装包下载_开源镜像站-阿里云
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
说明 由于官方CentOS服务器可能不稳定或已停用,所以更换为更稳定的国内镜像源。通过替换/etc/yum. repos . d/Centos- Base. repo文件中的内容来实现这一点。