How to Install PHP 7 in CentOS 7

The CentOS 7 official software repositories have PHP 5.4 that is reached end of life and no longer actively maintained by the developers.

Thus you need a newer PHP 7 on your CentOS server.

The commands below will help you install PHP 7 on CentOS. All of them are executed as root account or with sudo


Installing PHP 7 on CentOS 7

1. To install PHP 7, you have to install and enable EPEL and Remi repository to your CentOS 7 system with the commands below.

2. Next, you need to install yum-utils, a collection of useful programs for managing yum repositories and packages. It has tools that basically extend yum’s default features.

It can be used for managing (enabling or disabling) yum repositories as well as packages without any manual configuration and so much more.

3. One of the programs provided by yum-utils is yum-config-manager, which you can use to enable Remi repository as the default repository for installing different PHP versions as shown.

If you want to install PHP 7.1 or PHP 7.2 on CentOS 7, just enable it as shown.

4. Now install PHP 7 with all necessary modules with the command below.

If you are going to use php-fpm:

Afterwards, check the installed version of PHP on your system.

 

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com