Site icon Ryadel

How to install PHP 7 on Linux CentOS

PHP - How to disable error log, display errors and error reporting programmatically

Since we recently posted an article about downgrading from PHP 7.2 to PHP 7.1 on CentOS, we thought that it could be useful to add a post explaining how to install it in the first place. As a matter of fact, it's not as easy as typing sudo yum install php  on our linux terminal window, as the PHP build officially supported on CentOS 7.4 is still PHP 5.6.

Step 1: Add the Repository

The first thing we need to do is to add the proper repository to our CentOS machine. In order to do that, navigate to the /etc/yum.repos.d/  folder and add one of the following files, depending if you want to install PHP 7.0 , PHP 7.1 or PHP 7.2:

PHP 7.0

This file contains the URLs pointing to the Remi's RPM Repository for PHP 7.0. For this very reason, we suggest to call this file remi-php70.repo or something like that.

PHP 7.1

This file contains the URLs pointing to the Remi's RPM Repository for PHP 7.1. For this very reason, we suggest to call this file remi-php71.repo or something like that.

PHP 7.2

This file contains the URLs pointing to the Remi's RPM Repository for PHP 7.2. For this very reason, we suggest to call this file remi-php72.repo or something like that.

Step 2: Enable the Repository

Now that we added the repository, we need to ensure that our CentOS machine will ask us to fetch the PHP version we want to install. To do that, we have to enable the corresponding repository using one of the commands below:

For PHP 7.0

For PHP 7.1

For PHP 7.2

Step 3: Install PHP

As soon as we added the proper repository by creating the .repo file in the /etc/yum.repos.d/  folder, we can proceed with the standard yum install  command: as our CentOS machine will automatically find the proper repo:

Needless to say, you can add (or remove) any other php extension you might want to setup for your system, such as: php-soap, php-pecl-zip and so on.

If we did everything correctly, we'll have PHP installed on our CentOS machine in less than a minute.

 

Exit mobile version