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.

  • Nice post Taylor. I was thinking about switching from PHP 5.3.29 to PHP 7. I will test it out first to see if its really worth it to update my already existing installation. You know what they say? If it’s not broken, don’t fix it. ;-) Amazon AWS default EC2 AMI instances offer the ability to install php70 by default so it shouldn’t be to hard to update. Here is the command: “yum install php7-pear php70-fpm php70-gd php70-json php70-ldap php70-mbstring php70-mcrypt php70-odbc php70-pecl-imagick php70-snmp php70-soap php70-xml php70-xmlrpc php70-mysqlnd php70-opcache php70-pdo”. If you are interested in my test results about php 5 vs php 7 for a basic WordPress installation, just let me know.