清理现有EPEL配置
# 移除旧版EPEL(强制卸载)
sudo yum remove epel-release -y
清理缓存和元数据
sudo yum clean all
sudo rm -rf /var/cache/yum/*
确认系统版本(关键步骤)
cat /etc/redhat-release
CentOS 7用户需确保系统已更新至最新小版本(如7.9)
CentOS 8/Stream用户需使用dnf替代yum
重新安装EPEL
# CentOS 7
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# CentOS 8
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
注意:若官方源下载失败,可改用国内镜像(如阿里云):
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo # CentOS7