How To Update PHP For WordPress For Faster Site Speeds And Better Compatibility

How To Update PHP For WordPress
Pinterest Hidden Image

You should know by now that your site’s speed and performance are important for ranking higher in search results, increasing conversions, and improving the user experience.

Because of this, you’re probably already optimizing your site’s images, leveraging browser caching, and using a reliable hosting provider.

But when was the last time you thought about which PHP version your WordPress site was running?

WordPress works with PHP 5.6 and above. But seeing as the latest version is PHP 7.3, using anything less than that is just asking you to sacrifice your site’s speed, performance, and compatibility.

That’s why today we’re going to show you how to update PHP for WordPress. But first, let’s take a quick look at what PHP is and why it’s so important.

What is PHP and why should you care?

PHP is a server-side programming and scripting language that’s used to create dynamic websites. And, it just so happens that the WordPress core is primarily written using this open-source scripting language.

WordPress core php file

When someone clicks on a webpage that has PHP code, like your WordPress webpages do, the code is processed through your site’s server, is turned into HTML, and is displayed on the user’s screen as your website.

The neat thing about PHP is that you never have to learn it to run your WordPress website.

The only time you would ever really need to learn PHP (or any other kind of code for that matter), is if you wanted to develop WordPress themes, plugins, or customize your site using actions, filters, and possibly HTML and CSS.

That said, WordPress website owners do need to understand the importance of using an updated version of PHP.

Out with the old and in with the new PHP versions

According to W3Techs, PHP is used by over 79% of all websites in the world using a server-side programming language. And of course, that accounts for all WordPress websites, since PHP makes up nearly the entire CMS.

Just like any piece of software, PHP has a lifecycle that allows for continual advancements, patches, bug fixes, and improvements.

In fact, after its initial release, a new version of PHP is generally supported for 2 years until it earns the label “old” and a new version is released that is better to use.

Supported php versions
Source: PHP.net

The problem is, many website owners don’t know about this lifecycle or even which version their WordPress website is using.

Worse yet, they don’t understand that even switching to PHP 7.0 can have the following benefits:

  • Updating your PHP version to the latest release will keep the WordPress core safe
  • Using the latest version of PHP will guarantee other software, such as themes and plugins, will be compatible
  • PHP 7 is a higher standard of code and has better features for developers

Lastly, PHP 7 is a much leaner and efficient programming knowledge, which means it processes faster than ever and helps your site load blazing fast too.

You can check the results of just one (of many) speed benchmarking tests performed on several PHP versions and see for yourself just how fast the newer versions of PHP run.

Php benchmarkiting for speed
Source: Cloudways

Of course, WordPress works with PHP 5.6 and above. But think about this. PHP 5.6 hasn’t been actively supported since the beginning of 2017, with security support ending in January of 2019. And yet, 27.3% of WordPress users still use it.

WordPress users and php version use
Source: WordPress.org

Not to mention, 15.5% of people still use PHP 7.0 (which is significantly faster than PHP 5.6) but has not been supported since the beginning of 2019. And you guessed it, by the end of 2019, yet another version, PHP 7.1, will bite the dust when it comes to security support.

This leaves only PHP 7.2 and PHP 7.3 as those versions being actively supported, complete with security fixes and all.

So, what are 71.1% of WordPress website owners doing using PHP versions that are either at the end of their lifecycle or nearing it? Well, hopefully learning about the importance of PHP and updating very, very soon!

How to check which version of PHP your WordPress site is running

Okay, so you know that using an updated version of PHP is important. But before you go trying to update your PHP, first check under the hood and see which version your WordPress website is currently using.

The easiest way to do this is to go to Tools > Site Health in your WordPress dashboard. Then, click on the Info tab.

Site health and info tab

Next, scroll to the Server dropdown and see which version of PHP your site is using.

Php version

If you find that you’re using an outdated version of PHP, it’s time to fix that!

Make sure your web host supports the latest PHP versions

There are many reasons why WordPress site owners don’t update their PHP version:

  • As we mentioned above, many people don’t know or care about their PHP version. This means that unless a developer or web host informs them that an update is due, it won’t happen.
  • Developers find that updating website, theme, and plugin code for newer PHP versions takes too much time.
  • Updating also requires extensive testing for compatibility whenever a website is updated to a newer version of PHP. Developers and website owners alike don’t want to deal with this hassle or the problems that may occur afterwards.

Lastly, some hosting companies are hesitant to push out updated PHP versions.

New PHP versions mean a possible increase in site crashes because of compatibility issues, which mean an increase in support tickets. Little do they understand that the majority of problems are actually going to come from customers using an outdated version of PHP.

In the end, there’s no reason why all WordPress websites shouldn’t update their PHP versions. Unfortunately, one of the biggest obstacles to updating PHP is actually the hosting companies and their refusal to support higher versions.

Worse yet, in this article titled “Whipping Your Hosting Into Shape,” Joost de Valk goes into detail about how many web hosts that do support updated versions of PHP fail to encourage their users to make the upgrade, which is just as bad as not providing the newer version in the first place.

That’s why the next step after figuring out which version of PHP your website uses is to check with your web host and see which versions they support.

And if you find that they don’t support the newest version of PHP, it’s probably time you look elsewhere for WordPress hosting.

Now it’s time to update your PHP version with cPanel

The way to update your PHP version is through the cPanel (or similar) in your web hosting account. But first, we recommend you make a backup of your site, just in case something goes wrong.

We also recommend you test the PHP update locally, or in a staging environment before pushing it live to ensure there will be no compatibility issues.

Step 1: Create a copy of your site

To start, create a copy of your website, complete with all its files and the database. Sometimes even using a backup of your site will give you enough to work with.

Step 2: Create a local or staging site

Set up a testing environment, whether locally or using a staging environment if your web host provides one. Add the copy of your website to your testing environment so you have an exact replica of your live site.

Next, update the PHP on your test site and begin the process of testing for compatibility issues.

Step 3: Check PHP compatibility

You’ll need to go through your test site to make sure nothing has broken with the PHP update. This means checking the functionality and design of your site to ensure everything still works and looks right.

Here are some helpful PHP compatibility tools to help:

  • PHP Compatibility Checker: This is a great tool for checking for incompatibility issues all the way up to PHP 7.3. There are some limitations, as some plugins are known to cause false positives. But it will give you a good start.
  • Error Log Monitor: This plugin adds a dashboard widget to your site that displays the latest messages from your PHP error log. You can also opt to receive email notifications too. Whether you’re a developer or not, this plugin is the perfect solution for getting help when you need it.
  • WP_DEBUG: Though not an actual “tool,” turning on the debug mode throughout WordPress will help you view PHP messages so you can address them.

If you find any issues on your test site during this process, work to find solutions. This may include changing plugins or themes that are compatible with newer PHP versions.

Compatible plugins

Just don’t forget to make the same changes on your live site once you’ve resolved the issue on your test site!

Step 4: Change PHP version in cPanel

After you’ve tested everything on your local site, it’s time to update your PHP version in real life. To do this, log into your cPanel and find the section for managing PHP versions.

Manage php version

Next, choose the directory (or website, depending on how your cPanel is set up) that you want to upgrade.

Choose directory

When you do this, you’ll then have the option to choose which PHP version you want to use. And if you’re really lucky, your web host will even have a managed PHP version that will automatically update when needed.

Choose php version

Need specific instructions for updating your PHP version using your web host? Here’s a list with instructions for updating the PHP version for 32 different web hosts.

Final thoughts

Using the newer versions of PHP is crucial if you want your website to maintain its fast loading times, stay secure, and continue to be compatible with new themes and plugins that hit the market.

While WordPress continues to work with older versions of PHP, and the cycle will continue as PHP versions die and new ones release, it only makes sense to optimize your website in all the ways you can. And that means using the fastest loading, highly secure, and most compatible PHP version possible.

So, check out which version of PHP your WordPress site is using and make a change if you don’t like what you see. You and your site visitors will be happy you did.