How do I enable the EPEL repository for my Amazon EC2 instance running CentOS, RHEL, or Amazon Linux?

Last updated: 2020-05-18

I have an Amazon Elastic Compute Cloud (Amazon EC2) instance running CentOS, RHEL, or Amazon Linux. How do I enable access to the Extra Packages for Enterprise Linux (EPEL) repository to allow installation of packages that are not available in standard repositories?

Short Description

Standard repositories might not provide all the packages that can be installed on CentOS, Red Hat Enterprise Linux (RHEL), or Amazon Linux-based distributions. Enabling the EPEL repository provides additional options for package installation.

Resolution

Follow these steps to download, install, and enable the EPEL repository on RHEL, CentOS, or Amazon Linux-based distributions:

Amazon Linux

Amazon Linux 2:

Install the EPEL release package for RHEL 7 and enable the EPEL repository.

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Amazon Linux Amazon Machine Image (AMI):

The EPEL repository is already installed on the original version of Amazon Linux, but you must enable it. You can enable this repository either by using the yum-config-manager command or by editing the epel.repo file.

sudo yum-config-manager --enable epel

RHEL

RHEL 8:

Install the EPEL release package for RHEL 8. Enable both the EPEL and CodeReady Builder repositories. The CodeReady Builder repository contains development tools required by many EPEL packages.

sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf config-manager --set-enabled rhui-codeready-builder-for-rhel-8-rhui-rpms

RHEL 7:

Install and enable the EPEL release package for RHEL 7.

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

RHEL 6:

Install and enable the EPEL release package for RHEL 6.

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

CentOS

CentOS 8:

Install the EPEL release package for RHEL 8. Enable both the EPEL and PowerTools repositories. The PowerTools repository contains development tools required by many EPEL packages.

sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf config-manager --set-enabled PowerTools

CentOS 7:

Install and enable the EPEL release package. CentOS 7 includes the epel-release package in the base repositories.

sudo yum install -y epel-release

CentOS 6:

Install and enable the EPEL release package for RHEL 6.

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

List enabled repositories

To verify that the EPEL repository is enabled, run the repolist command.

sudo yum repolist