What comes to mind when you think of WordPress speed and security? Your favorite plugins, perhaps? You should also think about… PHP!

If you’re looking for a site that loads fast, while offering a solid shield against hacker attacks, there’s a highly effective solution linked to the famous programming language.

A man has a solution.
Drum roll…

Here’s the solution: update the PHP version of WordPress. Yes, quite simply. Well, simple in a manner of speaking.

Though the operation isn’t very complex and doesn’t require coding, there are several steps and rules to follow to avoid causing problems.

If you’re interested, I’ll explain everything in this article. Once you’ve read it, you’ll have a step-by-step method for changing your PHP version, if need be.

You’ll be able to make the updates without fear, to the benefit of your future visitors. Let’s get on with the adventure!

Your best WordPress projects need the best host!

WPMarmite recommends Bluehost: great performance, great support. All you need for a great start.

Try Bluehost
CTA Bluehost WPMarmite

What is PHP?

PHP (a recursive acronym for PHP: Hypertext Preprocessor) is a general-purpose, open-source scripting language designed to develop dynamic web pages.

With 78% market share, it’s the world’s most widely used server-side programming language, ahead of ASP.NET, Ruby, and Java.

As its official documentation explains, PHP integrates easily with HTML. Its code “is executed on the server, generating HTML which is then sent to the client.”

An example of PHP code.
An example of PHP code from the language’s official documentation.

We’re particularly interested in PHP because it’s the main programming language on which WordPress is built.

And the version of PHP on which your site runs, managed at the level of the server of your hosting provider, is of vital importance in a number of respects (performance, security) that I’ll explain later.

Hence the need to update the PHP version of your WordPress site, if necessary. 😉

Which PHP versions are compatible with WordPress?

PHP and delivery cycles

At the time of writing, the most recent version of PHP is 8.2. It’s worth noting that the programming language works in delivery cycles.

On average, a new version of PHP — also known as a branch — is released every year, usually at the end of the year (November–December).

Each new PHP branch is actively maintained for two years from the initial stable release. During this period, reported bugs and security issues are corrected and released in regular point releases.

For example, PHP 8.2.4 and PHP 8.2.5 brought fixes to the PHP 8.2 branch.

During the third year, support is maintained for each branch, but only for security issues deemed critical.

After 3 years, the branch reaches End Of Life (EOL) and is no longer maintained. This exposes it to security vulnerabilities that will not be corrected.

In summary, as I write these lines, the 3 PHP versions still being maintained are:

  • PHP 8.0
  • PHP 8.1
  • PHP 8.2
A list of the three currently-supported versions of PHP.
Source

This means that the previous versions (7.4, 7.3, 7.2, etc.) have reached the end of their life. As you can understand, it’s best to avoid using them for security reasons.

What does WordPress recommend when updating PHP?

In its prerequisites for running the CMS (Content Management System), WordPress indicates that your web host should support at least PHP version 7.4.

The reason that WordPress doesn’t insist on PHP version 8.0 or higher is mainly for potential compatibility issues.

Indeed, if your site doesn’t run on a recent version of the CMS (the latest available is 6.3), using a maintained version of PHP (8.0, 8.1, or 8.2) could potentially generate display errors and/or cause your site to crash.

And with almost 40% of users still using a version less than or equal to 6.1, prevention is better than cure.

Pie chart of WordPress versions by number of users.

But ideally, it’s better to use a PHP branch greater than or equal to 8.0. Which raises a question…

Is WordPress compatible with PHP 8?

As explained in this article published by the WordPress “Hosting” team, it all depends on the version of the CMS you’re using. Here are its recommendations, as of May 2023:

  • If you’re using WordPress 6.2: Activate at least PHP 8.1 on your hosting server. As things stand, only 9.7% of WordPress sites use this version (and barely 2.5% use PHP 8.2).
Pie chart of the percentage of users for each PHP version.
  • If you’re using WordPress 5.9 to 6.1: PHP 8.1 should do the trick.
  • If you’re using WP 5.6 to 5.9: Switch to PHP 8.0.
  • If you’re using a version lower than 5.6, update WordPress first, using our article and this resource.

In all cases, remember this rule of thumb: it’s essential to use an up-to-date version of WordPress AND PHP.

Why should you update the PHP version of your WordPress site?

For a faster site

There are several advantages to updating the PHP version of your WordPress site. The first relates to your site’s performance.

According to the official WordPress documentation, “Your website may be faster because PHP becomes more efficient with each new version. Updating to WordPress’s recommended version… can deliver a performance increase that will benefit all visitors to your website.”

Having a site that loads quickly is important for improving:

  • The user experience, notably in terms of Core Web Vitals. These are taken into account by Google to position a page in its search results.
  • Your bounce rate. If it decreases, your visitors will visit more pages on your site and be more inclined to perform certain specific actions.
  • Your conversion rate. If a visitor is no longer browsing your pages, you have no chance of achieving conversions (an action you want your visitor to perform, such as purchasing a product).
    As an example, the giant Amazon reported that it lost 1% of its sales every time its page load time increased by 100 ms.

To go further and turn your site into a rocket ship, check out our guide, “How to speed up a WordPress website without breaking the bank“.

To enhance your site’s security

Beyond performance, updating PHP on your WordPress site also reinforces your website’s security.

As you’ve seen, as soon as a PHP version reaches the end of its life, it’s no longer maintained. If any security flaws are detected, they will not be corrected.

As PHP is a very popular open-source programming language, it is logically the target of multiple hacker attacks (like WordPress).

As this resource details, an obsolete version of PHP exposes you more strongly to attacks of several types:

  • File inclusion vulnerabilities
  • XSS attacks (cross-site scripting)
  • SQL injections
  • Etc.

You should also know that WordPress 6.3 will no longer support PHP 5. The minimum supported version will be 7.0.0.

This doesn’t mean you absolutely have to use PHP 7.0.0, though! Remember: only versions 8.0, 8.1, and 8.2 still receive security updates.

And by the end of 2023, PHP 8.3 will have arrived, meaning that PHP 8.0 will have reached the end of its life. Yes, already!

The security of your site must be taken very seriously. A hacker attack could have a negative impact on your business, not only in terms of your image, but also in terms of your bottom line (loss of sales, for example). At the very least, consider backing up your site regularly with a dedicated plugin. Activate a general-purpose security plugin such as SecuPress or iThemes Security, and adopt best practices (strong passwords, for example).

To be able to install the plugins and themes of your choice

Finally, there’s one more important reason why you should update your PHP version of WordPress: without it, you may not be able to activate certain WordPress themes and plugins.

In fact, many of them require a recent version of PHP to function correctly. If you don’t have this, you won’t even be able to install them.

The following message will appear on your screen: “This plugin does not work with your version of PHP”:

Many plugins require an updated PHP version to function.
I can’t install the Rank Math plugin on my WordPress site, ouch.

That’s annoying, isn’t it? To solve this problem, I’m now going to show you how to avoid frustration. ^^

How do you know which PHP version you’re currently using?

Before we move on to the technical side of things and the modus operandi for updating your PHP version on WordPress, there’s one important detail you need to find out: your current version of the programming language.

Indeed, if your WP site is running on a recent and still-maintained version (e.g. PHP 8.1 or PHP 8.2), there’s no need to go to the effort to change things.

It’s easy to find out. On your WordPress dashboard, go to the Tools > Site Health menu:

The Site Health tool in the WordPress menu.

In the “Info” tab, click on the “Server” section. You’ll then see your PHP version.

In the example below, PHP 8.1.9 is active:

The PHP version in use on WordPress is visible in the Site Health tool.

What should you do? At the very least, you’ll need to comply with the WordPress prerequisites. To date, the CMS recommends at least PHP 7.4.

If your version is lower than this, you’ll need to update it.

As you know, the PHP version to activate also depends on your current WordPress version. For simplicity’s sake, we’ll use the two most recent major versions of WP.

So if you’re using WordPress 6.2 or 6.3, ideally you should upgrade to PHP 8.2 (or at least 8.1).

Now let’s take a closer look at how to do it.

6 steps to upgrading PHP on WordPress

By way of foreword, here’s an important clarification. In the majority of cases, updating the PHP version of WordPress goes without a hitch.

However, as with any theme or plugin update, there is always the possibility of a bug, error, or incompatibility. By applying the precautions detailed below, you’ll limit these possible problems.

Finally, as the WordPress documentation explains, remember that “there are far more risks involved in not updating your PHP version.”

Step 1: Back up your site before updating PHP on WordPress

First and foremost, back up your WordPress site. In the event of a problem, you’ll be able to restore it and get back to where you were before making any changes.

The quickest and easiest way to do this is to use a plugin.

One of the most popular is called UpdraftPlus:

UpdraftPlus: WordPress Backup & Migration Plugin banner

Easy to learn, it lets you schedule automatic backups and send your backups to a remote storage space (e.g. Google Drive or Dropbox), which is a real plus.

To find out how, take a look at our tutorial article for this plugin.

Do you manage the maintenance of several sites? If so, I recommend an all-in-one tool like WP Umbrella. From the same dashboard, you can perform backups and updates of your various sites with a single click. It’s a real time-saver.

WP Umbrella : Manage all your WordPress websites under one dashboard

Update your themes and plugins, monitor and backup your WordPress sites effortlessly. 

Try WP Umbrella
wp umbrella

Step 2: Update WordPress

Once you’ve backed up your site, you’re ready for the rest of the process. The second step is to update your website. This involves three aspects:

  • Your active theme and any installed themes
  • Your plugins
  • Your WordPress version

When an update is available, WordPress notifies you in Dashboard > Updates.

To perform an update, select the theme, plugin, or WordPress version concerned. Then click on the button corresponding to the update:

Updating plugins on WordPress.

For more details, see our article on how to update WordPress safely.

Step 3: Check your site’s compatibility with the PHP version to be updated

Now, let’s say you have a clean database. Your site is saved and up to date. Perfect.

Now it’s time for step 3 of your mission, which is to update your PHP version on WordPress.

At this stage, it’s important to check your site’s compatibility with the PHP version to be updated.

In principle, if you’re using one of the latest major versions of WordPress, everything should work with one of the latest branches of PHP.

But it’s best to be as careful as possible. 😉

To do this, you have several options:

  • WordPress recommends that you activate the PHP Compatibility Checker plugin to discover possible incompatibility risks. However, WordPress points out that: “This plugin isn’t perfect and may miss elements or bring up false positives, but it works well in most cases“. If any errors are found, contact the people developing the plugin or theme concerned directly via their support, WordPress adds.
PHP Compatibility Checker banner
  • More tedious: you can also check the compatibility of each theme or plugin with the version of PHP you’re planning to activate. You’ll find this information on their official directory page and/or in their documentation.

Join the WPMarmite subscribers

Get the last WPMarmite posts (and also exclusive resources).

WPMarmite English newsletter

Step 4: Migrate your site locally

Have you corrected any errors? In theory, you should now be able to update your PHP version on your production site. Everything should work.

However, I recommend that you err on the side of caution. First, migrate your online site to a local environment so you can test it without any risk.

Wondering how to do this? Here are the instructions!

Use a migration plugin

First of all, use a migration plugin like All-in-One WP Migration or Duplicator.

Without coding, it will enable you to copy your entire online site (database + files) to your local environment.

Please note that the free versions of most migration plugins impose limits on the total size of files to be migrated. All-in-One WP Migration, for example, won’t let you go beyond 512MB in its free version.

Create a local site with… Local

When your site is ready for migration (most of the time, you’ll have your files and database in a zip file), deploy a local site.

To do this, use a tool like… Local, which we present here in great detail.

When installing this tool, it’s important to choose the PHP version you wish to update on your production site.

To do this, during the process of adding a new site, set up a customized environment by clicking on “Custom.” Then select the PHP version of your choice:

Using Local by Flywheel to update the PHP version.

Once the site is installed, copy your online site “on top” using the archive saved with your migration plugin.

With All-in-One WP Migration, for example, you first need to activate the plugin on your local site. Then import your archive by going to All-in-One WP Migration > Import > Import from > File.

Importing a file with the All-in-One WP Migration plugin.

Finally, check that your site is up to date and that everything is running smoothly.

If you see no obstacles on the horizon, you can proceed to the next step.

Step 5: Updating PHP on the production site

Return to your online site’s administration interface. Check one last time that everything is up to date (themes, plugins, and WordPress core) and functional.

Is everything OK? Then it’s time to update the PHP version of your WordPress site in production.

To do this, go to your hosting account’s control panel. This is usually either cPanel or Plesk, depending on your hosting provider.

bluehost (affiliate link), for example, the hosting provider that WPMarmite recommends, offers cPanel.

To log in, you’ll need a username and password, which you’ll find in the welcome email your host sent you when you subscribed to their service.

Once you’ve logged on to cPanel, click on the “Select PHP version” module in the “Software” box:

Selecting PHP version in cPanel.

Then select the PHP version you require (e.g. 8.2) from the drop-down menu to the right of “Current PHP version”:

In cPanel, you can choose your PHP version from a dropdown menu.

If all goes well, your site will update itself in a fraction of a second. Congratulations: you now have an up-to-date PHP version.

If it’s impossible to update your PHP version via the interface provided by your hosting provider, contact them for more information and to ask them how to proceed. To help you, the WordPress documentation provides this ready-made (and very useful) email:

An example email you could send to your hosting provider to request a PHP update.

Step 6: Test your site’s functionality

Finally, make sure your site is working properly. That is, without display errors or bugs.

You can do this by:

  • Navigating through the various pages/posts of your site and see if any errors appear
  • Testing the operation of your theme and plugins
  • Check performance gains with a free online tool like Google PageSpeed Insights

In the vast majority of cases, you’ll be fine. If you encounter any problems, here’s what you can do:

  • Restore the previous PHP version, following the procedure detailed in step 5.
  • Consult our guide to the main WordPress errors (and how to fix them) to help you resolve a problem.
  • Contact your web host to explain the problem and ask if they can help you resolve it.
  • Ask for help in WordPress community forums.
  • Call on a WordPress maintenance specialist like WPSitter.

Do you need help with WordPress?

WPSitter manages maintenance, security, bug fixes and optimization of your WordPress site for you 24/7.

Conclusion

Updating the PHP version on WordPress is a recommended operation to reinforce your site’s security and improve its loading speed.

In turn, you’ll improve your visitors’ user experience and your SEO. What’s more, you’ll multiply your chances of improving conversions.

That’s why it’s important to get started as soon as possible. Thanks to this tutorial, you’ve got no more excuses.

You have a step-by-step method for switching to an up-to-date and properly maintained PHP branch.

Is this something you’re familiar with? Share your feedback and any tips you may have in the comments.