centos7配置虚拟机yum源 1.移除源文件yum源配置 2.配置阿里云yum源 3.清除源,查看yum源列表,并建立缓存 4.按配置阿里云epel-7源 的代码
时间: 2024-02-22 20:52:25 浏览: 209
以下是配置CentOS 7虚拟机yum源的代码:
1. 移除源文件yum源配置
```shell
sudo rm -rf /etc/yum.repos.d/*.repo
```
2. 配置阿里云yum源
```shell
sudo tee /etc/yum.repos.d/CentOS-Base.repo <<-'EOF'
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://mirrors.aliyun.com/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7
enabled=1
EOF
```
3. 清除源,查看yum源列表,并建立缓存
```shell
sudo yum clean all
sudo yum repolist
sudo yum makecache
```
4. 配置阿里云epel-7源
```shell
sudo tee /etc/yum.repos.d/epel.repo <<-'EOF'
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://mirrors.aliyun.com/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7
enabled=1
EOF
```
阅读全文