How to install PHP version 7 on centOS7

Posted in php, blog on November 4, 2020 by wiblok ‐ 1 min read

How to install PHP version 7 on centOS7

at first

As a memorandum, I needed to install PHP on Linux’s centos7.

Add repository

Even if you try yum install without preparing anything, there is no php7 in the centOS standard repository. That’s why we need to use an external repository.

Let’s add the EPEL repository, and then the Remi repository, where php is always up-to-date and provided.

Add EPEL repository Execute the following command to add EPEL repository.

[user@ip-123-45-67-891 ~]$ sudo yum install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.advancedhosters.com
 * extras: mirrors.advancedhosters.com
 * updates: mirrors.advancedhosters.com
~~~~~~~~
~~~~~~~~
Installed:
  epel-release.noarch 0:7-11

Complete!

Add Remi repository

Add the Remi repository by running:

[centos@ip-172-31-21-151 ~]$ sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

Retrieving http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
warning: /var/tmp/rpm-tmp.BuE36r: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Preparing... ################################## [100%]
Updating / installing...
   1:remi-release-7.6-2.el7.remi ################################### [100%]

Install latest PHP

As a trial, I will install the latest PHP7.2 on May 20, 2019.

yum install --enablerepo=remi,remi-php71 php

that’s all. good job for today.