Which PHP Version to Use With WordPress?

tools-toolbar-wp-admin.png

PHP versions, what are they? And why should you care? Just as you may speak English, German, Italian, Portuguese, Spanish or one of the many other languages in the world. There are also various languages for programming.

One such language is
PHP, the language that WordPress is predominantly written in. And the language
version number your site uses can have a significant impact on your website’s
loading times.

In this guide, we’ll be exploring more about which PHP version to use for WordPress, along with the implications of using older PHP versions.

Without further ado,
let’s get started!

What PHP Versions are Compatible
With WordPress?

Now, WordPress works
with PHP versions as old as PHP 5.6, along with:

  • PHP 7.0
  • PHP 7.1
  • PHP 7.2
  • PHP 7.3
  • PHP 7.4

However, all PHP versions prior to PHP 7.3 are end of life (EOL), meaning they no longer receive updates. Because of this, your site may be exposed to security vulnerabilities.

WordPress themselves recommend running PHP 7.3 as a
minimum
and also state:

“Note: WordPress also works in legacy environments with PHP 5.6.20+ and MySQL 5.0+. But these versions have reached official end-of-life and, as such, may expose your site to security vulnerabilities.”

It’s not just the
security implications though of running an older PHP version, it’s the
performance impact as well. According to PHPBenchmarks, PHP
5.6 is at least 47% slower than PHP 7.3

Such a vast difference
in performance is incredible. Imagine updating your PHP and seeing an
instantaneous performance rise of 47%! There’s nothing else you can do to your
website that’d have such a tremendous impact on load times in such a short
space of time.

How to Find out Which PHP Version
You’re Using

Now you understand more
about the performance gains you can get from upgrading your WordPress PHP
version, how do you go about finding out which PHP version you’re currently
using?

In WordPress 5.2, a tool was introduced called “Health Check” before this Health Check was a separate plugin that you could install.

In this guide, we’ll
assume you are using WordPress version 5.2 or above, and if you aren’t,
definitely update ASAP!

Head over to your wp-admin and hover over “Tools”:

tools toolbar wp admin

You should see “Site Health.” Go ahead and click that. And then you’ll be on the main Site Health tab that’ll show various information and highlight aspects that need attending to. Click on the “Info” tab:

site health info tab

You’ll see various items that you can click
on, but the one that we care about is the server. Click that, and you’ll then
see the server information like so:

server info on wordpress dashboard

Under the PHP version,
you can see our test site is running PHP 7.3, so we’re all good! But what if we
were running an older version of PHP? Like PHP 5.6? Let’s take a look at what
we’d need to do to upgrade it.

The Advantages of Upgrading Your
PHP Version:

Advantage 1: Speed

Ok, ok. We talk about
speed a lot, but it’s a critical factor of any good website. You could have the
best product in the world, the most beautiful website. Yet if it loads slowly,
no one is going to buy your product or stay on your website.

Advantage 2: Increased Security

If you’re running either
PHP 5.6, PHP 7.0, or PHP 7.1, did you know that your website isn’t protected?

That’s right, all those
PHP versions are what’s known as EOL or end of life. That means they don’t
receive any updates, whether that be for security or bug fixes.

By using an older
version of PHP, you are automatically putting your website in danger. Even
those who are running
PHP 7.2 are at risk with support ending soon.

While we aren’t saying
you’re going to be hacked if you are using an older PHP version, it certainly
plays into the nefarious hands of the third-party. Keep safe and upgrade to PHP
7.3 or PHP 7.4.

Advantage 3: Maintained

Maintenance. What
happens when there’s a bug in PHP? Well, what happens in most instances is at
some point, the bug is fixed, and web hosting companies automatically apply the
patch to their servers, and you never even notice.

Yet…what about bugs when
a PHP version is EOL? Well, unfortunately, you’re out of luck! The only way you
can fix it is by upgrading to a newer PHP version.

Upgrading when it isn’t
critical (e.g., your website isn’t broken) is much safer, as the upgrade isn’t
done in a hurry, and you have more time to test.

But having to upgrade
because there’s a problem with the version you currently use isn’t ideal at
all.

Greater compatibility with
newer software

We’re already seeing
WordPress plugins like MailPoet shift to dropping support within their plugin
for older PHP versions.

In fact, MailPoet has dropped support for PHP 5.6 altogether, and if you try and use MailPoet with PHP 5.6, you’ll just see an error notice asking you to upgrade.

And this is a trend
that’ll continue as newer versions of PHP introduces new features and
functionality that developers want to implement within their software, and
often to do this they have to drop support for older PHP versions.

The latest version of WooCommerce also dropped support for PHP 5.6. While as an end-user, you may feel hard done by to no longer have your software work with older PHP versions, developers are doing it with your best interests at heart as well.

Disadvantages of Using an Older PHP Version

PHP Errors

Have you ever upgraded
your WordPress version, a plugin, or a theme and then come across an unexpected
error?

Maybe you’ve seen
something like:

PHP Parse error: syntax error, unexpected ‘::’ (T_PAAMAYIM_NEKUDOTAYIM)

This is an error that
you’ll see if you upgrade to something that uses the double colon operator, and
your website runs a PHP version less than 5.3.

Or maybe you’ve seen an
error like this:

Parse error: syntax
error, unexpected ‘’ (T_VARIABLE), expecting function (T_FUNCTION)

Again this error is
something you’ll see if you use a PHP version that’s older than 5.3, and you
upgrade a plugin or theme that doesn’t support such an old PHP version.

As we mentioned above,
most plugins now require PHP 5.6 as a minimum, a few require PHP 7, and some
recommend PHP 7.3 as a minimum.

In short, you want to
make sure you are using the newest WordPress PHP version, both for performance
and to prevent any unexpected errors.

How to Safely Upgrade Your
WordPress PHP Version

Now upgrading your PHP
version doesn’t have to be scary or feel like taking a leap into the unknown.

Of course, as with
anything that revolves around software or anything technical, there is always
the possibility of issues arising, whether that be in the shape of bugs, failed
upgrades, or anything in-between.

That’s why we’re showing you how to safely upgrade your PHP version and remember if you still aren’t happy about performing it yourself, you can always hire a professional through a service such as codeable for doing it for you.

Exactly how you upgrade
your WordPress PHP version will largely depend on who you host with. Most
managed WordPress hosts already have detailed guides that you can follow (we’ll
link to those below).

But we’re also going to show you how to upgrade your WordPress PHP version using Siteground, why Siteground? Simply because Siteground is our recommended host that offers blazing-fast managed WordPress hosting at great prices.

So before we get started
with showing you how to upgrade your PHP version, let’s first start with making
sure you’re doing it safely.

Step 1: Use a Staging Site

Ideally, you’ll first
have an exact replica of your website in a development environment (also known
as a staging site) where you can apply the PHP version change to check before
upgrading your live site.

The benefits of using a
staging site over a live site are numerous and include:

  • No revenue loss — If you upgrade your live
    website and it breaks, you’re going to lose revenue one way or another. By
    breaking a staging site and fixing it, you can then upgrade your live site safely.
  • Time — When you upgrade your WordPress PHP
    version on a staging site, you have time on your side, you can test over a
    couple of days and ensure everything works fine. When you upgrade on a live
    site, you’ll be testing quickly. You can easily miss things that are broken,
    causing a negative user experience.
  • Reputation stays intact — If you upgrade your
    live website and it breaks, your reputation is going to take a hit, and people
    may stop visiting your site. By upgrading on your staging site, should any
    issues arise, then you can solve them first without damaging your reputation.

Step 2: Backup Your Website First

While this should go
without saying, it’s absolutely crucial that you backup your WordPress website
first. How though?

Head on over to your wp-admin > plugins > add new and search for “Updraft”:

searching for updraft plugin

Click on “Install now” and then click activate and you’ll be taken to the tour/setup wizard:

installing and activating updraft

Click on “Press here to start!”. And then on the next page click “Backup now”:

first backup list on updraft
new backup on updraft

Ensure that “Include your database in the backup” and “include your files in the backup” is checked (it should be by default).

Once you’re happy with everything, click on “Backup now” within the modal.

Depending on the size of the backup, it’ll
take from a couple of minutes to 30 minutes or so. Once the backup is complete
you’ll see a success message, and you should see an existing backup in your
list:

existing backups on updraft

And congrats! You’ve now successfully backed
up your WordPress website, ready to upgrade your WordPress PHP version. But
where is the backup stored?

Well, by default, the backup is stored on your
server, so you’ll want to download that. Here’s how.

Step 2a: Downloading Your Backup

In your wp-admin > Settings > UpdraftPlus Backups, scroll down to existing backups, and you should see all your backups listed like so:

downloading a backup on updraft

Here you can click on
each item:

  • Database
  • Plugins
  • Themes
  • Uploads
  • Others

Clicking on an item will
find the item on your server and then allow you to download the file to your
computer.

So go ahead and click on
each one and download it. Once everything has been downloaded, you can be more
at ease with upgrading your PHP version, knowing you can restore your website
should the worst happen.

Step 3: Ask Your Host

Your host is another way
to upgrade your PHP version safely, still don’t forget to take a backup first
(after all things can go wrong). But generally, your host will be able to
report any issues and check your website’s error log for you.

In fact, we’d actually
recommend asking your host to upgrade your PHP version before doing it yourself
or hiring an expert. And because of that, we’ve written a short template letter
you can send to your host.

“Hi there,

I’d like the PHP version of my WordPress website to be upgraded to at least PHP 7.3 for the performance and security benefits.

Can you please upgrade my PHP version for me and let me know if subsequently there are any new errors in my website’s error log caused by the PHP upgrade?

Thanks!”

Straightforward and to
the point. In our experience, most web hosts are more than happy to upgrade
your WordPress PHP version for you.

Step 4: Hire an Expert

The final step to safely
upgrading your WordPress PHP version is to hire an expert. Yes, while it’ll cost
you a little money, the peace of mind is often worth it.

You can find experts to
help you at various job boards such as:

Of course, keep in mind
when hiring someone, it’s like giving them the keys to your house, you need to
trust them and be confident they know what they are doing. How can you stay
safe?

  1. Give them their own account — don’t share your own passwords and accounts. Create them new unique accounts.
  2. Ask questions.
  3. Research them — do they have a background in what you need done? Can you find any negative reviews of them online?

As a general guide,
unless you have a crazy complex website, it shouldn’t take someone more than 3
hours to upgrade your PHP version and test the website that everything works.

Upgrading Your PHP Version with Siteground

Step 1: Access Development Tools

Open up your Siteground control panel for your website, and you should see something like this:

siteground dashboard

On the left hand side you’ll see a menu item called “Devs”. Click on that and you’ll see the PHP Manager:

devs php manager on siteground

Step 2: Managing Your PHP Version
With Siteground

With the PHP manager open your screen should
like this:

devs php manager on siteground

Now you’ll see a couple
of different things here, including:

  • Current version — the current version of PHP that
    is being used for your WordPress website. In our case, this is PHP 7.1.
  • PHP Variables — You don’t need to worry about
    this section. This is to enable and disable different variables and modules of
    PHP. In 99.99% of instances, you’ll never need to touch this.

Click on the pencil icon under the “PHP version” section:

arrow pointing to pencil icon on siteground

You’ll now see that there’s an option of both managed PHP and unmanaged PHP. However, managed PHP isn’t available on all Siteground plans, only those that are part of their “Managed WordPress plans”.

change php version menu on siteground

If you leave your version as “Managed PHP” Siteground will automatically upgrade the server your website is hosted on to the latest stable version of PHP that they support.

Step 3: Switching Your PHP
Version

Sometimes the managed PHP version isn’t
suitable for your website though after all our website is set to PHP 7.1.
Still, we could see performance improvements with PHP 7.4. What do we do?

Click in the dropdown box under “Set PHP version” and select “Change PHP version manually.

selecting option on siteground to select php version

You’ll then be able to see the various
versions of PHP that you can upgrade and downgrade from/to:

selecting php version on siteground

In this instance we want our website to use the latest version of PHP which is PHP 7.4.2. Click on that, then click “confirm” and you should see a success message:

successfully changed php version on updraft

And that’s it! You’ve now successfully upgraded your PHP version on Siteground.

Updating Your PHP Version Manually on Your Server

If you run your own server either as a
dedicated server or a VPS (Virtual Private Server), then you’ll want to take a
look at PHP’s official documentation on migrating your PHP version.

If you run your server on a platform like SeverPilot then you can upgrade your PHP version quickly and easily. Here’s how.

Upgrading Your PHP Version Using
ServerPilot

Open up your SeverPilot account and click on “Apps”, then click the app name. You should then see a page like this:

server pilot dashboard

Then where you see “PHP version” click on the pencil icon next to that and you can then select the PHP version you want from the displayed dropdown:

selecting php version on serverpilot

Select the PHP version you want from the dropdown list (in our case that’s PHP 7.4) and then click on “Update”.

Your PHP version will be changed and that
should reflect in your app like so:

server pilot dashboard

Congrats! You’ve now successfully updated your PHP version using ServerPilot.

Conclusion

Upgrading your WordPress PHP version is vital
for both the performance and security of your website.

Although it may seem overwhelming at first,
upgrading is more straightforward than it first appears, and whether you
upgrade the version yourself, ask your hosting company or hire an expert,
there’s a solution for everyone.

Have you upgraded your PHP version? Or maybe
you’ve run into an issue when upgrading your PHP version? Let us know in the comments
below.

The post Which PHP Version to Use With WordPress? appeared first on Astra.


This post was originally posted here

Check out our Starter Sites built with #ToolWeLove including Toolset, Elementor Pro, and Astra Pro.

 

Share this page
Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on email
How to Choose WordPress Hosting

Pixallus WordPress Hosting. Simplified. Enjoy blazing fast WordPress website loading speeds and 99.9% uptime. Whether you’re a freelancer, small business, or a large organization, we

Read More »
sendinblue