WordPress is one of the widely used platforms across the world. Main reasons behind its popularity is open-source nature and easy to use for non-tech guy. 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!
The Process of Benchmarking
We tested WordPress version 5.2 against different versions of PHP.
- Server Configuration: Linode with 2 cores processor, 7.15GB RAM, and 50GB SSD
- PHP versions: 5.6, 7.0, 7.1, 7.2
- Dummy content (10 posts per page) generated from wptest.io
- Number of concurrent users: 15
- Duration: 60 seconds
- OPCache memory: 128MB
We wanted to test out WordPress in its default state that’s why we used pre-installed Twenty Seventeen WordPress theme.
The Result of Benchmarking
The graph above shows the result obtained from benchmarking. The trend shows constant improvement in handling requests per seconds from PHP version 5.6 to 7.2. According to this result, PHP 7.2 is an obvious winner whereas 7.1 was a little behind.
This result of our 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 and for instance, if a site is currently working on PHP 5.6 or 7.0, then it’s recommended to upgrade it to the latest version of PHP.
Now let’s examine each and every PHP version separately to find out the reasons behind WordPress performance in the benchmarking.
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 the latest and the most updated version of PHP. The major updates include security patches, better codability, deprecation of old PHP functions, and improved performance.
Unfortunately, PHP 7.2 is being used by less than 3% of the WordPress sites. Even though, it improve WordPress performance better than its predecessors and is also recommended by WordPress itself. PHP will be actively supporting this version until November 30, 2019, and security support until November 30, 2020.
Source: WordPress Stats
Over these years PHP fixed its issues and launched some great features which open-source is adopting gradually. Being a WordPress user, you should also consider upgrading to the latest version of PHP for better performance and security. The older version will eventually get deprecated and will have no or limited support by theme and plugin developers.
Source: PHP Supported Versions
How to Upgrade PHP Version in WordPress?
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 PHP version in WordPress.
Note: Before you proceed, please back up WordPress site as some plugins might have compatibility issues. Then create a local clone of WordPress site which uses your desired version of PHP to test out its performance. For that, 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 as 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.
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 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.2.
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.