After only recently realising we were running PHP 5.3, a release that came out a good seven years ago, we thought it a good time for an upgrade. Unfortunately due to CentOS’ stance on long term support, rather than the bleeding edge, this task at first proved quite difficult. As of now for CentOS 6, and I believe CentOS 7, there is no readily available package for upgrading to PHP 7.
Much to our luck we eventually came across an article going over the details of setting up PHP 7 on a CentOS Virtual Private Server (VPS), I’ve included a link to said article at the bottom of this post.
Installing PHP 7
Installing PHP 7 went surprisingly smoothly. The first requirement was to remove what was the currently installed PHP Apache module. To do this we entered the following command:
yum remove php*
The above command removes all installed packages beginning with PHP, before you do this we do very much recommend you take a backup of everything first just in case anything goes terribly wrong.
The next step involves downloading the latest version of PHP 7, which at the time of writing this article is PHP 7.0.2. The following command downloads the latest PHP repository to your current directory:
The final step assumes you will be using PHP for a standard WordPress installation:
yum install php70w php70w-opcache php70w-mysql
If everything has gone as expected a simple restart of your Apache server should result in a working PHP installation. To check whether PHP 7 has installed correctly we’d recommend running the phpinfo(); function.
As we use Cloudflare to aggressively cache our blog’s pages, upgrading to PHP 7 had very little impact on our frontend performance. Those of you who aren’t currently using a CDN or some form caching should see their page loading times half.
Having said the above, our WordPress admin is certainly much more responsive.