Yum repositories are like websites that you can download software from. Yum has default repositories to download packages so you do not need to configure repos to use yum to install/upgrade packages on your system. But that is not enough. Some packages do not exist on default repositories,then you need to add new repositories to install software from those repos. The most needed repo is epel - Extra Packages for Enterprise Linux 7. You can enable it using
1 |
yum install epel-release |
Some packages do not even exist on epel such as php7 on centos7. CentOS7 only has php 5. To install php7 on CentOS7, you need to add a new repo called remi repo.
How to add the remi repository? To add a new yum repo, Redhat’s official document says you should use the command “yum-config-manager –add-repo repository_url”. But other posts say you should use the following command:
1 |
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm |
In fact, this command will install a bunch of new repos and their CPG Key files on your system:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
/etc/pki/rpm-gpg/RPM-GPG-KEY-remi /etc/pki/rpm-gpg/RPM-GPG-KEY-remi2017 /etc/pki/rpm-gpg/RPM-GPG-KEY-remi2018 /etc/pki/rpm-gpg/RPM-GPG-KEY-remi2019 /etc/pki/rpm-gpg/RPM-GPG-KEY-remi2020 /etc/pki/rpm-gpg/RPM-GPG-KEY-remi2021 /etc/yum.repos.d/remi-glpi91.repo /etc/yum.repos.d/remi-glpi92.repo /etc/yum.repos.d/remi-glpi93.repo /etc/yum.repos.d/remi-glpi94.repo /etc/yum.repos.d/remi-modular.repo /etc/yum.repos.d/remi-php54.repo /etc/yum.repos.d/remi-php70.repo /etc/yum.repos.d/remi-php71.repo /etc/yum.repos.d/remi-php72.repo /etc/yum.repos.d/remi-php73.repo /etc/yum.repos.d/remi-php74.repo /etc/yum.repos.d/remi-php80.repo /etc/yum.repos.d/remi-safe.repo /etc/yum.repos.d/remi.repo |
Every .repo file in /etc/yum.repos.d/ directory means a new yum repository. The repo directory is specified as the reposdir option in /etc/yum.conf. But using the “yum repolist” command, you can see only one remi repository:
1 |
remi-safe Safe Remi's RPM repository for Enterprise Linux |
That is because the “yum repolist” command only shows the enabled repositories. To see all installed repos, you need to use “yum repolist all”. You can see most repos on your system are disabled. To enable a repository, you need to issue the following command:
1 |
yum-config-manager --enable remi-php74 |
The above command enables the remi-php74 repository. You can check the file /etc/yum.repos.d/remi-php74.repo to verify the repo is indeed enabled: there is a line “enabled=1″ under the [remi-php74] section. With the remi php7 repo enabled, you can install the php7 packages from that repo now:
1 |
yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd php-xml php-mbstring php-pear php-ldap php-xmlrpc php-snmp php-soap curl curl-devel |
Yum will download packages from http://cdn.remirepo.net/enterprise/7/php74/mirror (specified as the mirrorlist option under the [remi-php74] section in /etc/yum.repos.d/remi-php74.repo), then install them on your system. The downloaded packages are also cached in /var/cache/yum/. You can clear the cache using:
1 |
yum clean all |