我想在 Amazon Elastic Compute Cloud(Amazon EC2)实例中启用 Extra Packages for Enterprise Linux(EPEL)存储库的访问权限。该实例正在运行基于 CentOS、Red Hat Enterprise Linux(RHEL)或 Amazon Linux 的发行版。
解决方法
要在基于 CentOS、RHEL 或 Amazon Linux 的发行版上下载、安装和打开 EPEL 存储库,请根据发行版运行以下一种命令。
要确定正在使用的发行版,请运行以下命令:
cat /etc/os-release
Amazon Linux
Amazon Linux 2023
Amazon Linux 2023(AL2023)不支持 EPEL。有关详细信息,请参阅 Extra Packages for Enterprise Linux(EPEL)。
Amazon Linux 2
要安装 RHEL 7 的 EPEL 发行包,请运行以下命令:
sudo amazon-linux-extras install epel -y
RHEL
RHEL 8
要安装 RHEL 8 的 EPEL 发行包,请运行以下命令:
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
RHEL 7
要安装 RHEL 7 的 EPEL 发行包,请运行以下命令:
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
CentOS
CentOS 8
要安装 RHEL 8 的 EPEL 发行包,请运行以下命令:
sudo sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
sudo dnf config-manager --set-enabled PowerTools
**注意:**此命令同时开启了 EPEL 和 PowerTools 存储库。
CentOS 7
要安装 EPEL 发行包,请运行以下命令:
sudo yum -y install epel-release
注意: CentOS 7 包含基础存储库中的 epel-release 包。
验证 EPEL 存储库是否开启
若要验证 EPEL 存储库是否已开启,请运行以下 repolist 命令:
sudo yum repolist
相关信息
How can I use these extra packages? on the Fedora website
Add repositories on an AL2 instance
AL2 Extras Library
Amazon Linux 2 FAQs