The standard (official) RHEL/CentOS repositories offer a small number of basic packages that do not always contain the latest versions of programs. However, you can use third-party public or private repositories to install new programs in Red Hat Enterprise Linux, CentOS, Oracle Linux and Scientific Linux. Remi and EPEL are the most popular third-party repositories. In this article, we’ll look on how to install, manage and use additional repositories with the yum (dnf) package manager in CentOS.
How to Enable EPEL and Remi Repository in CentOS?
When you install an OS (in our example, it is CentOS 7), basic repositories are installed by default. You can view the list of them using the command:
yum repolist
As you can see in the screenshot, there are 3 repositories installed in the system — base, extras, updates. These are enough to start installing basic software and additional repositories.
Let’s consider how to install extra repositories in CentOS.
EPEL may be the most popular repository today.
It is very easy to install EPEL in CentOS 7 (unlike CentOS 6) using RPM package (it is the easiest method to add a new repo):
yum install epel-release
After being installed, the repository appears in the repo list without any actions (you do not need to clear the yum cache).
To install Remi repository on CentOS, run this command:
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
If there is no RPM package for the repository you need, you can add it by creating a config file .repo in /etc/yum.repos.d manually (see the next article section).
To understand, which repositories the packages are installed from, you can display the full list of packages:
yum list installed
As you can see, every package has the information about the repository it is installed from (there are base, update, epel and anaconda repos on the screenshot below).
You can display the list of packages available for installation in a specific repo:
yum repo-pkgs epel list
Repository Configuration Files (*.repo)
All repository configuration files are located in /etc/yum.repos.d/ and have the *.repo extension. A typical config file contains the following parameters:
- name — the repository name
- baseurl — the link to a repository (it may be ftp://address, http://address, https://address or file://address for a local repo)
- enabled – whether this repo must be used: 1 — the repo is enabled, 0 — the repo is disabled;
- async – whether to use parallel package downloading (auto/on/off)
- gpgcheck – whether to perform a GPG check (1 — the check is on)
- gpgkey — a link to a GPG key
- exclude — the list of excluded packages
- includepkgs — the list of included packages
- mirrorlist – the list of repository mirrors
The smallest repo file may look like this:
[rep_name] name=rep_name baseurl=rep_url
For example, after you have install the REMI repository, some Remi (remi-*.repo) configuration files will appear in the repository directory.
As you can see, Remi has a separate configuration file for each PHP version. You must enable the PHP version you need via the config file. For example, I will have PHP 7.3 installed on my server, so I have enabled the corresponding repo (I have specified enabled=1
in remi-php73.repo
):
You can connect the repository manually. To do it, create a repository configuration file in /etc/yum.repos.d/. Let’s add the MariaDB repo.
nano /etc/yum.repos.d/mariadb.repo
Add the data provided by MariaDB package developer to it:
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.4/centos73-amd64/ gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
How to Disable a Repository in CentOS?
In order to disable one of the installed repositories, it is enough to specify enabled=0 in its configuration file.
Then clean the yum cache:
yum clean all
And recreate it:
yum makecache
After that remi-php73 repo won’t be used when you install or update packages.
If you do not want to use a repository only for the current package update/installation command, you can disable it in the yum command, for example:
yum update —disablerepo=epel
In this example, we have disabled EPEL and updated installed packages.
You can temporarily disable all repositories you do not need. For instance, to update packages only from MariaDB repository, run the command:
yum update --disablerepo "*" --enablerepo=mariadb
To disable or remove repos, the yum-config-manager that belongs to yum-utils tools is used.
Install yum-utils:
yum -y install yum-utils
Disable a repository, for example, remi:
yum-config-manager --disable remi
To remove a repository completely, you must remove its configuration files and update yum cache.
How to Check Repo for Available Package Updates?
You can check a specific repository for available package update.
yum check-update --disablerepo "*" --enablerepo=mariadb
Thus, you can manage the connected repos on your server. Note that different repositories may contain the same packages, and version conflicts may occur during update. So leave only the repositories you work with enabled.
Popular ThirdParty Repositories for CentOS and RHEL
MariaDB repo, as you can guess by its name, contains MariaDB packages. The repository has been created by MariaDB developers, it is constantly supported and updated.
To install this repository in the system, create a .repo file with the following contents:
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.4/centos73-amd64/ gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
Like the previous repository, Nginx contains packages related to the nginx HTTPD server.
To install the nginx repo, create a .repo file and add the following text here:
[nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/CentOS/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key
This list of repositories is enough to configure the so-called LAMP stack with nginx as a front-end server.
This repository list may be enough for almost any user, however, I will give some more examples.
Webtatic is supported by a limited number of experts, mostly it is Andy Thompson. It contains PHP related packages, but it is less popular than Remi, since the latest PHP version in this repository had been 7.2 by the time this article was written.
yum repo-pkgs webtatic list | grep php7
mod_php71w.x86_64 7.1.31-1.w7 webtatic mod_php72w.x86_64 7.2.21-1.w7 webtatic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ php72w-tidy.x86_64 7.2.21-1.w7 webtatic php72w-xml.x86_64 7.2.21-1.w7 webtatic php72w-xmlrpc.x86_64 7.2.21-1.w7 webtatic
To enable the repository, install the following RPM package:
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
MySQL is what I want to remind of. I have not placed it together with the popular ones, since I think MySQL as a database server has lost its positions. MariaDB is usually installed on the servers instead. However, if somebody wants to install MySQL, you can enable this repo. For example, you want to install mysql 5.7:
Download the package:
wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
And install it:
rpm -Uvh mysql57-community-release-el7-9.noarch.rpm
After the installation I can install MySQL:
In this article, we have shown some aspects of repository management in CentOS and studied some useful repositories.