通常在国内使用 Linux 都需要修改镜像地址 ,因为默认的 http://mirrorlist.centos.org 被禁了,根本访问不了,也就无法下载各种包了,所以需要修改。
修改 Centos 镜像地址
文件位于 /etc/yum.repos.d/CentOS-Base.repo
修改前:里面的 http://mirrorlist.centos.org 域名国内完全不能访问,所以需要修改。
vi /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS - $releasever - Base
# mirrorlist=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
baseurl=https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# released updates
[updates]
name=CentOS - $releasever - Updates
# mirrorlist=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
baseurl=https://mirrors.aliyun.com/centos/7.9.2009/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# additional packages that may be useful
[extras]
name=CentOS - $releasever - Extras
# mirrorlist=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
baseurl=https://mirrors.aliyun.com/centos/7.9.2009/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# additional packages that extend functionality of existing packages
[centosplus]
name=CentOS - $releasever - Plus
# mirrorlist=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
baseurl=https://mirrors.aliyun.com/centos/7.9.2009/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
验证
输入下面命令来验证。
yum repolist