Recently, we were having some performance issues here at WPLift. 502 errors. Server slowdowns…it wasn’t fun stuff.
The quest to fix those issues led us to this post, which we hope acts as both a source of motivation and guidance on this very important topic:
The PHP version that your WordPress site’s server is running. Specifically, why you need to use the latest version, and how you can make that happen.
Sexy, right? Everyone loves a good night out discussing PHP versions with friends.
But despite it not being the most exciting of topics, it’s super important for your WordPress site.
In this post, I’ll first explain:
- Why PHP versions matter
- Why you shouldn’t use old PHP versions (even though most WordPress sites do)
Then, I’ll share some tips for how to upgrade your WordPress site’s PHP version based on our own experience of moving WPLift to PHP 7.1.
What Are PHP Versions And Why Do They Matter?
Let’s start at the beginning…
This is pretty simple because, well, I’m not a developer. But here’s the big picture:
WordPress is primarily written in a scripting language called PHP. Whenever someone visits your website, the PHP code executes on your server and “builds” the HTML/CSS of your site to deliver to the visitor (side note – page caching plugins work by storing and serving up the static HTML end product of this process).
Article Continues Below
So when it comes to a WordPress site, PHP is what makes things hum.
But here’s the thing:
There’s no single “PHP”.
Just like WordPress has different versions – 4.9, 5.0, 5.1, etc. – PHP also has different versions. And while the different PHP versions all function similarly at a basic level, there are meaningful differences when it comes to performance and security (and the features/syntax that are available to developers)
If you’re following WordPress best practices, you wouldn’t dream of running an older version of WordPress. But when it comes to PHP versions, most WordPress users aren’t running the latest versions…or even anything close to the latest versions.
At the time that I’m writing this post, the most recent version is PHP 7.3.
However, according to the WordPress.org stats, 34% of WordPress sites – by far the plurality – are running PHP 5.6, which is four versions out of date at this time.
There’s no PHP 6, but the versions are still PHP…
That means PHP 5.6 is four versions back! That would be like running WordPress 4.6 instead of WordPress 5.0!
Beyond that, a whopping ~20% of WordPress sites are running PHP versions even older than PHP 5.6. As of March 2019, WordPress itself doesn’t even support anything under PHP 5.6, so that’s a pretty big deal.
Why Is It Bad To Use An Outdated Version Of PHP?
Next question – why is it bad that so many people use an outdated version of PHP?
First, there are huge performance differences between PHP 5.6 and PHP 7.1+.
According to Kinsta’s PHP benchmarks, PHP 7+ processes more than double the number of requests per second that PHP 5.6 does:
That alone is a pretty big incentive to upgrade, and it’s what helped us make WPLift a lot more stable.
But beyond that, older versions of PHP also no longer receive any updates, including security fixes. PHP 5.6 – and even PHP 7.0 – no longer receive either active or security support. That is, PHP 5.6 and PHP 7.0 have reached their end of life.
According to The PHP Groups’ website, that means:
“A release that is no longer supported. Users of this release should upgrade as soon as possible, as they may be exposed to unpatched security vulnerabilities.”
Finally, not all themes and plugins will support older versions of PHP. Most developers hate having to support older versions of PHP, and if you’re running something under PHP 5.6, some plugins and themes might just flat out not work.
Because of these issues, the WordPress core team has been trying to nudge people to upgrade their PHP versions. For example, as of WordPress 5.1, you’ll see a warning like this in your WordPress dashboard if you’re running a version under PHP 5.6:
Additionally, you’ll no longer be able to install plugins or themes that don’t support your version of PHP when you go to Plugins → Add New.
How To Upgrade WordPress to PHP 7
Now for the important part – how to actually upgrade your WordPress site/server to PHP 7.1+.
First – the good news. If you’re at a good host, the actual process of updating your PHP version should be super simple. Usually, you should get an option in your hosting dashboard that lets you make the switch without the need for any special knowledge.
If you’re struggling, I recommend reaching out to your host for support. And if your host doesn’t support PHP 7+, well…you should switch to one of our recommended WordPress hosts because that’s really bad.
However, changing your PHP version can break things, so you also need to take some other steps to ensure you come through unscathed.
Here’s what we did here at WPLift to ensure we had a smooth transition from PHP 5.6 to PHP 7.1…
1. Check For Any Compatibility Issues With Plugins Or Themes
While the WordPress core is guaranteed to work with PHP 7+, that doesn’t necessarily mean that all your plugins and themes will.
Now, any quality developer should have long ago made sure that their plugins and themes are compatible, but to double check if that’s the case for your site, you should use a PHP compatibility checker tool.
You can run tests from the Environment Optimization tab in SG Optimizer:
And here’s what the WP Engine plugin looks like:
2. Use A Staging Site And Test Thoroughly
Once you’ve checked for any compatibility issues, set up a staging site on a server with PHP 7.1+.
This will let you test your site in a real-world environment and find any issues before you make the change on the live version of your site.
There are a few different ways to create a staging site on WordPress:
- Your host – many managed WordPress hosts offer dedicated staging functionality, including an option to use different PHP versions on the staging site.
- WP Stagecoach – WP Stagecoach is a standalone service/plugin that lets you create a staging site no matter your environment. This is what we used here at WPLift when we upgraded to PHP 7.1.
- Manual method – you can also just manually migrate your site to a new, private environment. It’s time consuming, but free!
3. Take a Backup Before You Make The Plunge
Once you’ve done a thorough test on your staging environment, you’re ready to take the plunge and upgrade on your live site.
However, before doing that, make sure that you take a full backup so that you have a recent backup on the off-chance that something goes wrong.
4. Test Your Live Site Thoroughly (Again)
Once you’ve upgraded the PHP version on your live site, give it another test to make sure there are no issues.
Pay special attention to things you might not have noticed on your staging site, like transactional emails that your WordPress site sends, or other behind-the-scenes actions.
Updating your WordPress site to PHP 7.1+ is a no brainer. The latest versions of PHP are faster, more secure, and guarantee that your site will continue to be able to take advantage of the latest plugins and themes.
If you haven’t already, set aside some time, do some testing, and then take the plunge by:
- Checking for compatibility issues using SG Optimizer or WP Engine’s plugin
- Testing thoroughly on a staging site
- Taking a backup before making changes on your live site
- Thoroughly testing your live site one more time
Since we moved WPLift to PHP 7.1, things have been much more stable both in the WordPress dashboard and on the front-end of our site, so it’s definitely worth it!
Have any questions about moving to PHP 7.1+? Ask away in the comments section!