How to Set Up and Use Yum Repositories on CentOS 7

Spread the love

This tutorial explains how to set up and use Yum repositories on a CentOS 7 VPS.

The official CentOS 7 repository has a huge list of packages and it covers almost all bases in terms of software for servers, but sometimes we need some additional packages which are not available in the official repositories. In that case, we can simply add new repositories to further expand the catalogue of packages available to us. Let’s begin with the tutorial.

Step 1. Login via SSH

Log in to your CentOS 7 VPS via SSH as the root user, or as an account with sudo privileges:

ssh root@IP_Address -p Port_number

Make sure to replace “IP_Address” and “Port_number” with your server’s IP address and SSH port.

Step 2. Update the OS Packages and Install the yum-utils Package:

Once you are logged in to the server, run the following commands to make sure that all installed packages are up to date:

yum clean all
yum update

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 high quality additional packages for enterprise Linux versions. 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 -Uvh

The output will appear as shown below:

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.

yum repolist

You should receive the following output, or something similar to it:

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                                         repo name                                                                      status
base/7/x86_64                                   CentOS-7 - Base                                                                9,901+10
epel/x86_64                                     Extra 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
repolist: 24,615

In order to see all of the packages available in the EPEL repository, run the following command:

yum --enablerepo=epel list | less

The output of this command will show you the list of packages.

Note: Other CentOS repositories that can be useful are located in /etc/yum.repos.d directory. When enabling some repository manually by editing the .repo file, make sure that the main 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:

name=CentOS $releasever – Base

name=CentOS $releasever – Updates

name=CentOS $releasever – Extras

Listing all repositories

To list all repositories, including all enabled and disabled repositories, run:

yum repolist all

Enabling a Yum Repository

To enable a Yum repository, run the following command as root:

yum-config-manager --enable repository <repository name>

Disabling a Yum Repository

To disable a Yum repository, run the following command as root:

yum-config-manager --disable repository <repository name>

Do not forget to replace <repository name> with the actual repo name.

If for some reason we cannot find the software package we need in the official and EPEL repositories, we can extend the capabilities of the server with even more software by adding additional repositories, like the Remi RPM repository, which is not an official repository of CentOS distribution but is well maintained and always up to date.

Remi Collet maintains a large collection of RPM packages, including the latest versions of PHP, etc. Please note that this repo does not always play nicely with other third party CentOS repos, so check the list of repositories using yum repolist and disable additional repositories if there are any package conflicts.

We can install the Remi repository using this next command:

rpm -Uvh

If for example we want to enable PHP 7.2 , we can edit the /etc/yum.repos.d/remi-php72.repo file and change enabled=0 to enabled=1 :

# This repository only provides PHP 7.2 and its extensions
# NOTICE: common dependencies are in "remi-safe"

name=Remi's PHP 7.2 RPM repository for Enterprise Linux 7 - $basearch

Another good unofficial CentOS repository is the 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 choosing and expand the functionality of your server in any way that you need to.

Of course, you don’t have to setup 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 admins to configure additional repositories on CentOS 7 for you, along with anything else that 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, please share it with your friends on the social networks using the sharing shortcut, or simply leave a reply below. Thanks.

3 thoughts on “How to Set Up and Use Yum Repositories on CentOS 7

  1. Das alles geht NICHT!!!!
    Immer kommt:login as: pi
    [email protected]’s password:
    Linux Server-Erwin 5.10.17-v8+ #1403 SMP PREEMPT Mon Feb 22 11:37:54 GMT 2021 aarch64

    root@Server-Erwin:/# yum upgrade
    There are no enabled repos.
    Run “yum repolist all” to see the repos you have.
    You can enable repos with yum-config-manager –enable

    I can not use YUM for CentOS 7-repository

    Wat is it? Can you help me?

Leave a Reply

Your email address will not be published. Required fields are marked *