This tutorial explains how to set up and use Yum repositories on a CentOS 7 VPS.
The official CentOS 7 repository has a huge package list and covers almost all bases in terms of server software, but sometimes we need some additional packages that are not available in the official repositories. In that case, we can simply add new repositories to further expand the catalog of packages available to us. Let’s start with the tutorial.
Log in via SSH
Log in to your CentOS 7 VPS via SSH as root user, or as a privileged account sudo:
ssh [email protected]IP_Address -p Port_number Be sure to replace “IP_Address” and “
Port_number” with your server’s IP address and SSH port
Step 2. Update the operating system packages and
install the yum-utils package: Once logged in to the
server, run the following commands to ensure that all installed packages are up to date
: yum clean all yum updates Install the yum-utils package
using the following command: yum install yum-utils
We can enable the EPEL (Extra Packages for Enterprise Linux) repository on CentOS 7 / RHEL 7, maintained by a special Fedora Special Interest Group that creates, maintains, and manages additional high-quality packages for enterprise versions of Linux. This includes Red Hat Enterprise Linux (RHEL), CentOS, Scientific Linux (SL), and Oracle Enterprise Linux (OEL).
Step 3. Install
the EPEL repository
To install the EPEL rpm, do so with the following command: rpm
The output will appear as follows:
Recovering https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm Preparing…#### [100%] Updating / installing… 1:epel-release-7-11 ##### [100%]
Check the newly installed repository. You should be able to find the EPEL repository in the list.
It should receive the following output, or something similar:
base | 3.6 kB 00:00:00 epel/x86_64/metalink | 11 KB 00:00:00 epel | 3.2 kB 00:00:00 extras | 3.4 KB 00:00:00 updates | 3.4 kB 00:00:00 (1/7): base/7/x86_64/group_gz | 166 kB 00:00:00 (2/7): base/7/x86_64/primary_db | 5.9 MB 00:00:00 (3/7): epel/x86_64/group_gz | 88 KB 00:00:00 (4/7): epel/x86_64/updateinfo | 934 KB 00:00:00 (5/7): updates/7/x86_64/primary_db | 6.0 MB 00:00:00 (6/7): extras/7/x86_64/primary_db | 204 kB 00:00:00 (7/7): epel/x86_64/primary | 3.6 MB 00:00:00 epel 12739/12739 Repo ID Repository name Base State/7/x86_64 CentOS-7 – Base 9,901+10 EPEL/x86_64 add-on packages for Enterprise Linux 7 – x86_64 12,739 extras/7/x86_64 CentOS-7 – Extras 432 updates/7/x86_64 CentOS-7 – Updates 1,543+71 Repository: 24,615
To view all packages available in the EPEL repository, Run the following command:
yum -enablerepo=epel list | The
result of this command will show you the list of packages
Note: Other CentOS repositories that may be useful are located in the /etc/yum.repos.d directory. When enabling some repository manually by editing the .repo file, make sure that the major version for CentOS is used in the repo file, in this case, it is CentOS 7.
For example, edit the CentOS-Base.repo file and add/modify these lines:
[base] name=CentOS $releasever – Base baseurl=http://mirror.centos.org/centos/7/os/$basearch/ gpgcheck=0 enabled=1 [updates] name=CentOS $releasever – Updates baseurl=http://mirror.centos.org/centos/7/updates/$basearch/ gpgcheck=0 enabled=1 [extras] name=CentOS $releasever – Extras baseurl=http://mirror.centos.org/centos/7/extras/$basearch/ gpgcheck=0 enabled=1
List of all repositories
To list all repositories,
including all enabled and disabled repositories
, run: yum repolist all
a Yum repository To enable a Yum repository, run the following command as root: yum-config-manager -enable repository <repository name>
a Yum repository
To disable a Yum repository, run the following command as root:
yum-config-manager -disable repository <repository name>
Don’t forget to replace <
repository name> with the actual repository name.
If for some reason we cannot find the software package we need in the official repositories and EPEL, we can extend the server capabilities with even more software by adding additional repositories, such as the Remi RPM repository, which is not an official CentOS distribution repository but is well maintained and always updated.
Remi Collet maintains a large collection of RPM packages, including the latest versions of PHP, etc. Note that this repository does not always work well with other third-party CentOS repositories, so check the repository list using yum repolist and disable additional repositories if there are any package conflicts.
We can install the Remi repository using the following command
: rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
If for example we want to enable PHP 7.2, we can edit the file /etc/yum.repos.d/
remi-php72.repo and change enabled=0 to enabled=1 : # This repository only provides PHP 7.2 and its extensions # WARNING: Common dependencies are in “remi-safe” [remi-php72] name=Remi’s PHP 7.2 RPM repository for Enterprise Linux 7 – $basearch #baseurl=http: rpms.remirepo. net/enterprise/7/php72/$basearch/ #mirrorlist=https://rpms.remirepo.net/enterprise/7/php72/httpsmirror mirrorlist=http://cdn.remirepo.net/enterprise/7/php72/mirror enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Another good unofficial CentOS repository is Webtatic Repo. This repository provides updated packages with later versions of PHP, MySQL, and other packages. With this information, you can now install any repository of your choice and extend the functionality of your server in any way you need.
Of course, you don’t have to install and configure additional repositories on CentOS 7, if you use our fully managed VPS support solutions, in which case you can simply ask our expert Linux administrators to set up additional repositories on CentOS 7 for you, along with anything else you might need. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to set up and use Yum repositories on a CentOS VPS, share it with your friends on social media using the share shortcut, or just leave a reply below. Thank you.