centos7 Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again

发布时间 2023-08-04 14:36:55作者: 闪光123

 

  1. 备份原始的 EPEL 存储库配置文件(可选):在更改前,建议您先备份原始的 EPEL 存储库配置文件,以便在需要时恢复到默认设置。在终端中执行以下命令备份:

    sudo cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
  2. 编辑 EPEL 存储库配置文件:使用文本编辑器(例如 nano 或 vi)编辑 EPEL 存储库配置文件 /etc/yum.repos.d/epel.repo

    sudo nano /etc/yum.repos.d/epel.repo
  3. 在编辑器中将原来的镜像源地址注释或删除,然后添加阿里云 EPEL 镜像源地址:

    [epel] name=Extra Packages for Enterprise Linux 7 - $basearch baseurl=https://mirrors.aliyun.com/epel/7/$basearch gpgcheck=1 gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7 enabled=1 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - $basearch - Debug baseurl=https://mirrors.aliyun.com/epel/7/$basearch/debug gpgcheck=1 gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7 enabled=0 [epel-source] name=Extra Packages for Enterprise Linux 7 - $basearch - Source baseurl=https://mirrors.aliyun.com/epel/7/SRPMS gpgcheck=1 gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7 enabled=0

    请注意,上述配置是适用于 CentOS 7 的配置。如果您使用的是其他版本的 CentOS,请替换对应的版本号。

  4. 保存更改:按下 Ctrl + O,然后按下 Enter 来保存更改。

  5. 退出编辑器:按下 Ctrl + X 来退出编辑器。

  6. 清除旧的缓存:在更改镜像源后,需要清除旧的缓存以便于重新生成:

    sudo yum clean all
  7. 生成新的缓存:执行以下命令来生成新的缓存,以便 yum 使用阿里云的 EPEL 镜像源:

    sudo yum makecache