After recently realising we were running an ancient version of PHP – version 5.3, we thought it a good time for an upgrade. CentOS has always been an advocate of don’t fix what is isn’t broken, rather than adopting the cutting edge. We hope this article will help you upgrade to PHP 7 on CentOS 6.

Installing PHP 7

The upgrade to PHP 7 went surprisingly smoothly. The first requirement was to remove the currently installed PHP Apache module. To do this we entered the following command:

yum remove php*

The above command removes all installed packages starting with PHP, this ensures we have a clean slate for installing PHP 7.

The next step involves downloading the latest version of PHP 7, which at the time of writing this article is PHP 7.1.1. The following command downloads the latest PHP repository to your current directory:

rpm -Uvh

The final step assumes you will be using PHP for a standard WordPress installation, the command below will install PHP 7 along with OpCache and the PHP driver for MySQL:

yum install php71w php71w-opcache php71w-mysql

If everything has gone as expected, a simple restart of your Apache server should result in a working PHP installation. To check whether your upgrade to PHP 7 has worked correctly, we recommend running the phpinfo(); function. If you see PHP version 7.1.1 then the installation has been a success. Finally, make sure you can see that OpCache and MySQLi are both enabled. The MySQL extension is required for running WordPress, and OpCache provides a nice performance boost to response times.

Updating to PHP 7.1.x

Minor versions of the latest PHP 7.1 release can be installed via the yum update and yum upgrade commands, when they become available. This will automatically remove the previous release and replace it with the new one. As with any upgrade you may need to restart Apache for the changes to take effect.



PHP 7 provides almost double the performance compared to PHP 5.6. We certainly noticed the difference when we first made the switch. Response times are significantly lower and page loads generally feel snappier.