WordPress is one of the widely used platforms across the globe. One of the reasons behind its popularity is open-source nature. But what makes WordPress an open-source platform? Well, the answer to that would be PHP. WordPress runs on PHP which is a scripting language contributing to around 83% of all the websites!
WordPress runs on PHP. But which version of the PHP allows for the best WordPress performance? To answer this, I have benchmarked a performance test on Cloudways managed WordPress hosting, in which I used different PHP versions and evaluated the number of requests processed per second.
The Process of Benchmarking
We tested WordPress version 5.1 against different versions of PHP.
- Server Configuration: Linode with 2 cores processor, 4GB RAM, and 48GB SSD
- PHP versions: 5.6, 7.0, 7.1, 7.2, and 7.3.
- Dummy content (10 posts per page) generated from wptest.io
- Number of concurrent users: 15
- Duration: 60 seconds
- OPCache memory: 128MB
I wanted to test out WordPress in its default configuration. That’s why I used the pre-installed Twenty Nineteen WordPress theme.
The Result of Benchmarking
The above graph shows the result of the benchmarking test. The trend shows constant improvement in handling requests per seconds from PHP version 5.6 to 7.3. According to this result, PHP 7.3 is an obvious winner whereas 7.2 was a little behind.
This result of this WordPress performance test also shows the compatibility between PHP and WordPress and the constant improvement it brings to your WordPress site. By looking at the results, WordPressers can easily understand the importance of updated PHP version. For instance, if a site is currently installed on PHP 5.6 or 7.0, I highly recommend upgrading it to the latest PHP version.
Now let’s examine each and every PHP version separately to find out the reasons behind WordPress performance in the benchmarking tests.
This version was released on August 24, 2014, and is one of the popular version of PHP used by many web frameworks as well as WordPress. As of today, more than 39% of the WordPress sites are still using this version.
PHP has ended active support in January 2017 but the security support is available until December 31, 2018. Despite being the most popular PHP version, its active support has been ended and a majority of plugin and theme developers have also stopped supporting this version which causes serious performance issues.
After 5.6, PHP did not release the 6th version. Instead, they released major version 7.0 on December 3, 2015. It came out with some major improvements in speed, type declarations, error handling, and secured user-land CSPRNG (random data generation). It had its active support until December 3, 2017, and security support until December 3, 2018.
More than 18% of the WordPress sites use this version and many plugins and themes still actively support this version. WordPress performance is satisfactory on this version.
PHP version 7.1 was released on exactly after one year of 7.0 on December 1, 2016. It had some fixes from 7.0 and a few additional features like iterable pseudotype, semantic array, nullable types, and void functions. Over 8.4% of the WordPress sites use this version.
As shown in the benchmarking results above, 7.1 performed very well as compared to its predecessors making it one of the stable and reliable versions having active support till December 1, 2018, and security support until December 1, 2019.
PHP 7.2 is still considered the recent popular version with major updates such as security patches, better codability, deprecation of old PHP functions, and improved performance.
Currently, just 18.3% of WordPress sites are running on PHP version 7.2 even though its performance, when compared to its predecessors, is better. PHP will actively support this version till Nov 30th, 2019 while security updates will be available till Nov 2020.
PHP version 7.3 is the latest and updated version. This version was released in Dec 2018. In addition to a few performance upgrades and bug fixes, 7.3 came out with the flexible heredoc and nowdoc syntax.
Unfortunately, PHP 7.3 is being used by less than 4.2% of WordPress sites. WordPress’s performance on this version is much better than its predecessors and the version comes highly recommended by the Official WordPress team. PHP will be actively supporting this version until December 2020, and security support until December 2021.
Source: WordPress Stats
Over the years, PHP fixed its issues and launched some great features which the open-source community is gradually adopting. Being a WordPress user, you should also consider upgrading to the latest WordPress PHP version for better performance and security. The older versions will eventually get deprecated and will have limited or no support by theme and plugin developers.
Source: PHP Supported Versions
How to Upgrade WordPress PHP Version?
After reading through this article, many of you might have made up your mind to upgrade current WordPress PHP version to the latest version to enhance WordPress performance. Don’t worry! We have also covered how to upgrade the PHP version in WordPress.
Note: Before you proceed, please back up WordPress site as some plugins might have compatibility issues. Next, create a local clone of WordPress site which uses your desired version of PHP to test out the performance of the installation. For this, you may use WAMP for Windows and MAMP for Mac.
Check for PHP Compatibility
Before we move to the latest version of PHP, let’s check the compatibility of our current WordPress. This is important in identifying which plugins or theme will be compatible with the new PHP version.
For that, we will use a WordPress plugin called PHP Compatibility Checker. Go to WordPress Dashboard → Plugins → Add New search for “php compatibility checker”, then install and activate the plugin. Now, go to Tools → PHP Compatibility to configure settings.
My current WordPress site is running on PHP version 5.6 and I intend to upgrade it to the latest PHP version, i.e., 7.2. Therefore, I check the box which says 7.2 to test the compatibility with this version and click Scan Site button to initiate the scan.
It will take a few minutes for the scan to complete depending on the number of plugins and themes installed. Then it will show the result like below to show which plugins and themes will be compatible with the chosen version and which might get compatibility issues.
The Green tag shows complete compatibility, Yellow shows that plugin can be fully compatible if updated, Red shows incompatibility which could be fixed by updating the plugin (if available) and Gray shows those entries which the plugin could not read.
As you can see, my WordPress version is mostly green so I am ready to move ahead for the PHP upgradation so I can acquire better WordPress performance.
There are two popular ways of upgrading the PHP version.
If you are using VPS or dedicated server then you can opt for this option. Download PuTTY to access your server using SSH. After installing, run PuTTY and access your server using its IP, username, and password. Go to your root directory and run the following command to confirm the current version of your PHP.
My PHP version is 5.6 which I need to upgrade to 7.2. To do that, I will write the following command in my SSH terminal.
apt install php7.2
Note: In order to run this command, you should be logged in as root.
Once the process is completed, run the php -v command again to confirm the latest PHP version installed on your WordPress site.
Upgrading PHP version through cPanel is comparatively easier than from SSH. To upgrade PHP version, log in to your cPanel, navigate to the Software section and click on Select PHP Version.
From the drop-down menu, select version 7.2 and click on Set as Current button to change the version.
I have now successfully upgraded my PHP version from 5.6 to 7.3.
How Can Cloudways Users Upgrade the PHP Version?
Cloudways users do not need to go through any of the above-mentioned processes. Cloudways Platform offers a simple process of changing PHP versions and it’s all done just by clicking on the desired version name. Let me show you how!
First of all, take advantage of Cloudways WordPress staging environment, make a clone of your live site by going to Application dashboard and hover the quick action buttons located on the bottom right corner.
Now clone your WordPress app in another server (which you may delete after you are done testing).
Once the site is cloned, navigate to your Server dashboard. From the dashboard, navigate to Settings and Packages, click on Packages and from the drop-down list, choose the latest version of PHP, then click on Save to initiate the process.
That’s it! It is that easy to change your PHP version using Cloudways Platform.
We saw WordPress performance on various PHP versions using the benchmarking process and tried to understand the importance of upgrading to latest PHP versions. We also learned a couple of ways to change PHP versions on the WordPress site. If you encounter any challenges or if you find performance improvements, feel free to share with us.
Start Growing with Cloudways Today!
We never compromise on performance, security, and support.
Ibad Ur Rehman is a WordPress Community Manager at Cloudways. He likes to explore latest open-source technologies and to interact with different communities. In his free time he likes to read, watch a series or fly his favorite Cessna 172SP in X Plane 10 flight simulator.