Is your WordPress site running on the latest PHP version?

PHP is the underline server-side programming language used by WordPress. PHP powers ~78% of sites, and surprised to find out ~43% of them use PHP 5.

Keeping PHP up-to-date is crucial for two reasons.

Performance

The latest PHP 7.x is two times faster.

Security

Using a supported version means if there are any vulnerabilities, it would be fixed on priority. The new version often contains bug fixes.

There is another factor – compatibility. If you are running on an older PHP version, then there is a chance that the new plugin may not support that.

WordPress officially recommend to use PHP 7.4 or greater.

What PHP version is your WordPress site on?

There are multiple ways to find out. But one of the quickest ways is by going to:

  • WordPress Admin >> Tools >> Site Health
  • Click on the Info tab.
  • Expand the Server section, and you would see the PHP version.
YouTube video

Congratulations if your WordPress is running on the latest PHP version.

You can refer to the official PHP site to find out the latest supported versions.

If your WordPress is on the older PHP version, then here is how you can upgrade to the latest.

cPanel

Most of the shared hosting offers cPanel and if you are using too, then updating PHP is just a matter of a click.

  • Login to your hosting cPanel
  • Search for PHP version on the top field
  • Click on Select PHP version
  • Click on the drop-down next to the current PHP version and select the latest one (at the time of writing, 7.4 is the latest one)
  • Click set as current
YouTube video

That’s easy!

If your cPanel doesn’t have the latest PHP version, then most likely, your hosting provider doesn’t offer that yet. You may speak to your hosting support and see if they can do it for you in the background. If not, you may want to move out to the platform that keeps their technology stack up-to-date, like A2 hosting.

EasyEngine

EasyEngine lets you set up and manage WordPress on cloud VM or VPS. It is based on Docker, and I’ve explained here how to use it.

If you are using EasyEngine, then you are one command away to update your WP site.

First, check out the supported PHP versions on their official site. Once you know which version you want to update to, you can execute the ee site update command as below.

  • Login to EasyEngine server
  • Execute the following command
ee site update $YOURSITE --php=$VERSION

$YOURSITE – your actual site name. If you don’t know your site name then you can execute the ee site list --enabled to find out.

[email protected]:~# ee site list --enabled
+---------------+---------+
| site          | status  |
+---------------+---------+
| geekflare.com | enabled |
+---------------+---------+
[email protected]:~#

$VERSION – the PHP version you want to update to

Below example for updating geekflare.com to 7.4 version

ee site update geekflare.com --php=7.4

It will take a few seconds to upgrade.

SiteGround

SiteGround is one of the popular hosting platforms for WordPress, Joomla, and other CMS. Lately, they have moved their infrastructure to Google Cloud and got their own panel to manage the site.

The excellent news is SiteGround automatically updates the PHP version to the most stable version; however, if you need to change that for whatever reason, it is possible.

  • Login to SiteGround
  • Go to the Websites tab and click on Site Tools next to the site you want to change
  • Go to DEVS at left navigation and PHP manager
  • Click on the pen icon next to the current version

  • It’ll open a popup where you can select change PHP version manually

  • Select the version you need and click confirm

It will take a few seconds and update your WP site’s PHP version.

Kinsta

Kinsta offers a premium managed WordPress hosting. Their infrastructure leverage Google Cloud and you can change the PHP through MyKinsta.

  • To do so, login to MyKinsta
  • Select the site  and go to the Tools tab
  • Modify under PHP engine

It will take up to 3 minutes, and you are all set!

CentOS 8.x

Are you managing WordPress yourself on DigitalOcean or other cloud VM?

Sure! You can easily upgrade PHP on CentOS 8.x as the following.

Default CentOS 8 will give you PHP 7.2.

[[email protected] ~]# php-fpm -version
PHP 7.2.24 (fpm-fcgi) (built: Oct 22 2019 08:28:36)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
[[email protected] ~]#

Let’s say you need to upgrade this to the latest one 7.4

First thing first, you’ll need to install the REMI repo with the DNF command.

dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Ex:

[[email protected] ~]# dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Last metadata expiration check: 1:37:58 ago on Tue 22 Sep 2020 04:22:02 PM UTC.
remi-release-8.rpm                                                                                                                               88 kB/s |  23 kB     00:00    
Dependencies resolved.
================================================================================================================================================================================
 Package                                    Architecture                         Version                                       Repository                                  Size
================================================================================================================================================================================
Installing:
 remi-release                               noarch                               8.1-2.el8.remi                                @commandline                                23 k

Transaction Summary
================================================================================================================================================================================
Install  1 Package

Total size: 23 k
Installed size: 17 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                        1/1 
  Installing       : remi-release-8.1-2.el8.remi.noarch                                                                                                                     1/1 
  Verifying        : remi-release-8.1-2.el8.remi.noarch                                                                                                                     1/1 

Installed:
  remi-release-8.1-2.el8.remi.noarch                                                                                                                                            

Complete!
[[email protected] ~]#

Let’s list the available PHP module with dnf module list php after we added the REMI repo.

[[email protected] ~]# dnf module list php
Last metadata expiration check: 0:00:33 ago on Tue 22 Sep 2020 06:01:25 PM UTC.
CentOS-8 - AppStream
Name                             Stream                                 Profiles                                               Summary                                          
php                              7.2 [d][e]                             common [d], devel, minimal                             PHP scripting language                           
php                              7.3                                    common [d], devel, minimal                             PHP scripting language                           

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name                             Stream                                 Profiles                                               Summary                                          
php                              remi-7.2                               common [d], devel, minimal                             PHP scripting language                           
php                              remi-7.3                               common [d], devel, minimal                             PHP scripting language                           
php                              remi-7.4                               common [d], devel, minimal                             PHP scripting language                           
php                              remi-8.0                               common [d], devel, minimal                             PHP scripting language                           

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[[email protected] ~]#

As you can see, 7.2 is the default and enabled but can activate another version, such as 7.3, 7.4, and 8.0. PHP 8.0 is still in beta, so it is not recommended for the live site.

Let’s enable 7.4.

dnf module enable php:remi-7.4

Once enabled, you should run the module list command to verify.

[[email protected] ~]# dnf module list php
Last metadata expiration check: 0:05:44 ago on Tue 22 Sep 2020 06:01:25 PM UTC.
CentOS-8 - AppStream
Name                             Stream                                  Profiles                                              Summary                                          
php                              7.2 [d]                                 common [d], devel, minimal                            PHP scripting language                           
php                              7.3                                     common [d], devel, minimal                            PHP scripting language                           

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name                             Stream                                  Profiles                                              Summary                                          
php                              remi-7.2                                common [d], devel, minimal                            PHP scripting language                           
php                              remi-7.3                                common [d], devel, minimal                            PHP scripting language                           
php                              remi-7.4 [e]                            common [d], devel, minimal                            PHP scripting language                           
php                              remi-8.0                                common [d], devel, minimal                            PHP scripting language                           

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[[email protected] ~]#

As you can see above, 7.4 is enabled now.

And, finally, we can install PHP 7.4 with dnf install as below.

dnf install php

Once done, check the version to verify.

[[email protected] ~]# php -v
PHP 7.4.10 (cli) (built: Sep  1 2020 13:58:08) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies
[[email protected] ~]#

Great!

Do you want to play around with PHP 8.0 beta version?

If yes, then run the below.

dnf module enable php:remi-8.0
dnf install php

And then verify the installed PHP version.

[email protected] ~]# php -v
PHP 8.0.0beta4 (cli) (built: Sep 15 2020 18:36:33) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.0beta4, Copyright (c), by Zend Technologies
[[email protected] ~]#

Ubuntu 18.x

The default repository of Ubuntu 18.x installs PHP 7.2, and to install PHP 7.4; we need to add the below repository..

add-apt-repository ppa:ondrej/php

And, then install

apt-get install php7.4

Let’s verify the installation.

[email protected]:~# php -v
PHP 7.4.10 (cli) (built: Sep  9 2020 06:36:14) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies
[email protected]:~#

Cloudways

Using Cloudways?

Why not!

They let you host your WordPress on DigitalOcean, Linode, Vultr, Google Cloud, AWS without going through the lengthy setup process. With one click, your WP is ready. Cloudways is a managed cloud hosting platform. It would be a perfect choice for anyone who wants to host a site on the cloud but doesn’t want to dirty the hands with the configuration, setup, and maintenance.

To change the PHP version on a server managed by Cloudways:

  • Go to the server >> Settings & packages.
  • Edit PHP version to select the desired version and save

It will take a few minutes to update the package on the server in the background.

Conclusion

Keeping website technology stack up-to-date is essential for performance and security. If you are still using the old PHP version on your WordPress, then you should consider upgrading them, as explained above.