如何为运行 CentOS、RHEL 或 Amazon Linux 的 Amazon EC2 实例开启 EPEL 存储库?
上次更新日期:2022 年 12 月 20 日
我想要开启 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 存储库可提供额外的软件包安装选项。
解决方法
按照以下步骤在 CentOS、RHEL 或基于 Amazon Linux 的发行版上下载、安装和开启 EPEL 存储库。
要验证分发,请运行以下命令:
cat /etc/os-release
Amazon Linux
Amazon Linux 2:
安装适用于 RHEL 7 的 EPEL 发行包并开启 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 发行包。同时开启 EPEL 和 PowerTools 存储库。PowerTools 存储库包含许多 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
CentOS 7:
安装并开启 EPEL 发行包。CentOS 7 的基本存储库中包括 epel-release 软件包:
sudo yum -y install epel-release
列出已开启的存储库
如需验证 EPEL 存储库是否已开启,请运行 repolist 命令:
sudo yum repolist