How To Install Epel Repo on CentOS 6 or 7
CentOS is one of the most reliable server operating systems. However, even CentOS does not include all RPM’s required to run and administrate your own web server. There are a bunch of great Repo’s you may want to install first, so you can use yum to quickly install a lot of packages
Warning: WHM / Plesk Servers Most Likely Do NOT Require This
Before you are trying to follow this guide, make sure your server requires it. WHM or PLESK servers usually don’t require it, unless you messed up the server and uninstalled the EPEL repo. To verify that you need the repo, go to your yum repo directory and verify there is no file called epel.repo
cd /etc/yum.repos.d dir
Sample Output: atomic.repo, CentOS-Base.repo, CentOS-Debuginfo.repo, CentOS-Media.repo, CentOS-Vault.repo, epel.repo, epel-testing.repo
Downloading The Correct Repo For Your CentOS Version (32-bit or 64-bit)
To make sure you install the correct repo, you first need to check your OS. If you don’t know what version of CentOS you are on (32-bit or 64-bit) then read this guide
1. Alright, the two most important URL’s for this where you can find all sorts of useful RPM’s are:
- 64-bit EPEL 6: https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
- 32-bit EPEL 6: https://dl.fedoraproject.org/pub/epel/6/i386/
- 64-bit EPEL 7: https://dl.fedoraproject.org/pub/epel/7/x86_64/
The direct link for the latest 6.8 EPEL Repo are below, please keep in mind that it is a good practice to always download the latest Repo. By the time you read this, 6.8 may no longer be the latest Repo. You can verify that by using the links above and searching for “epel”.
cd /root/scripts wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
cd /root/scripts https://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
cd /root/scripts wget https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
Adding REPO Key For EPEL 6 (CentOS 6) and EPEL 7 (CentOS 7)
If you have worked with rpm’s before, you will most likely know that you can install them with usually just one command. However, when trying to install the EPEL repo you will also need to install a key or you will get an error similar to this:
You need the key to verify you are obtaining a legit / unmodified copy of the repo.
To get a key, you can go to https://getfedora.org/keys/ – the direct link to the EPEL 6 (6 stands for CentOS 6 here) can be accessed using this link:
When you’re trying to download the key using an insecure connection you will get an error “certificate common name”. To connect to fedoraproject.org insecurely use –no-check-certificated
wget --no-check-certificate https://fedoraproject.org/static/0608B895.txt
Once you have it, run the following commands as well. We are creating a backup of your current key and then we will move the key we downloaded to the correct directory and then import it.
If you are on a WHM server, you should be aware that your cp is probably aliased, which means that in order to run cp -rf you will most likely have to enter \cp -rf to force overwrite. Finally, the last line imports your new key.
cp /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6.bak \cp -rf 0608B895.txt /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
For EPEL7 modify the commands.
Verifying That Your Key Got Installed Successfully
rpm -qa gpg*
Finally: Installing EPEL Repo via RPM
Execute this command:
rpm -ivh epel-release-6-8.noarch.rpm
Or for EPEL 7:
rpm -ivh epel-release-7-5.noarch.rpm
You should know get a message that the repo has been successfully installed. Personally, I am on a WHM server where the epel.repo already exists. If you intend to set up a webserver, I definitely urge you to shell out some extra money for a WHM / Cpanel license. Plesk is another alternative, but WHM is the industry standard and updated quite frequently.