8 minutes reading time (1600 words)

How do I update my PHP version?

September-PHP

Speed, security, compatibility, performance. These are just four of the reasons you should keep your PHP version up to date. In this 2020 revision on the topic, we cover a number of ways you can go about updating your PHP version to avoid problems in the lead up to the release of Joomla 4 which has a minimum requirement of PHP version 7.3 or above.

I’m getting a warning in Joomla about my PHP version not being supported when I log in as Administrator. Help!?!

If you’ve logged into your Joomla Administrator area and have been greeted with a message like the one above, don’t panic. Joomla has a recommended minimum PHP requirement at the time of writing of PHP 7.3 or higher. The current official release of PHP is version 7.4.

In addition to the PHP Version Check message that can appear if you’re using a version of PHP lower than 7.3, Joomla 3.10 will have a PHP warning message about PHP versions before you attempt to migrate to Joomla 4 when it is released.

With Joomla 4 a large amount of previous legacy code has been removed. At the same time, a lot of new modern code has been added. Having the correct version of PHP is going to be essential for Joomla 4 to work, as the new code utilises the improved features and functions PHP 7.3+ provides.

Recommended PHP Version and Technical Requirements for Joomla

Currently, Joomla 3 has a minimum PHP version technical requirement of 5.3.10, and since Joomla 3.5 was released in April 2016, the recommended version of PHP to be used for Joomla has been PHP 7. Since November 2019, the recommendation has been PHP 7.3+.

There’s a big reason behind the recommended version now being PHP 7.3+, and that’s due to PHP versions lower than 7.3 having reached end of life. So if your website is still using PHP 5.6 or earlier, or PHP 7.2 or earlier, then the possibility that your website will encounter compatibility issues with updates, or security issues due to vulnerabilities that can be exploited is much higher.

If your hosting provider is not providing you with the ability to use PHP 7.4 currently, then ask them why, and if they can’t, consider whether your hosting is working well for you.

Updating your PHP Version

There are a variety of ways to change your PHP version on your hosting, and it comes down mainly to which hosting platform your hosting provider is using.

Two of the most common hosting platforms available today are cPanel and Plesk, and so we’ll cover where you can typically find options to change your PHP version if your hosting provider has made that option available to you.

If you use cPanel or Plesk and the settings outlined below are not available to you, contact your hosting support as they might have disabled the functionality in shared hosting accounts on their servers.

If your hosting uses a custom control panel interface, then you may need to contact your hosting support to ask them to change the version of PHP available.

Upgrading PHP version in cPanel with EasyApache MultiPHP

  1. Log in to cPanel
  2. Find the “MultiPHP Manager” function by searching for “MultiPHP”, or find it in the Software section of the cPanel
  3. Make a note of your current version in case there’s a problem.
  4. Select the new version of PHP and click “Apply”. If there’s an option indicating the “inherit” option, that will mean that it continues to use the server’s default PHP version. However, depending on other aspects on the server this may not always apply correctly.
  5. Visit your site to confirm that the change has not broken your site.

Upgrading PHP version in cPanel with CloudLinux LVE

  1. Log in to cPanel
  2. Find the “Select PHP Version” function by searching for “PHP”, or find it in the Software section of the cPanel
  3. Make a note of your current version in case there’s a problem.
  4. Select the new version of PHP and click “Set as Current”. If there’s an option indicating the “native” option, that will mean that it continues to use the server’s default PHP version.
  5. Visit your site to confirm that the change has not broken your site.

 

Upgrading PHP Version in Plesk

  1. Log in to Plesk.
  2. Go to Plesk > Domains > [Your domain] > PHP Settings
  3. Make a note of the existing settings.
  4. Select the new version of PHP to use from the version dropdown. Also note the initial setting of the “run PHP as” option, as that might be something that is enforced by your hosting provider. If it changes when you select the PHP version, also change this value to match the previous value or you might end up with a system error.
  5. Click Apply
  6. Visit your site to confirm that the change has not broken your site.

Setting PHP version using AddHandler in .htaccess file

You can also use .htaccess files in Apache to switch your PHP version. You might find that in changing the cPanel PHP version, the following lines are added to your .htaccess automatically.

After changing cPanel to PHP 7.4 in the steps above, my .htaccess file now has the following contents:

What this line does is tell the server how to handle PHP files, by using a MIME Type to define the application version of PHP to use.

AddHandler application/x-httpd-ea-php74 .php .php7 .phtml

You can add a variation to your .htaccess file to switch PHP versions if your server supports that setting, and you already have other PHP versions installed.

Updating PHP version on a VPS or Dedicated Server

If you’re a server administrator or have your own VPS or Dedicated Server that you have root admin privileges for, you will usually be able to update your PHP version by adjusting the server settings.

If you’re not confident about making changes to your server, your provider’s support staff should be able to assist you with making the necessary changes.

Here are a number of resources on how to do that for different installations.

Update your WHM/cPanel server using EasyApache4

The simplest way to upgrade WHM so that the server has the latest version of PHP available, run EasyApache4 to update your Apache version, PHP versions and related modules.

Find out more…

Update your Plesk Server to install an additional PHP version

You can add additional PHP versions to Plesk via either the Plesk Administration interface for your server or via the command line interface.

Find out more...

Updating PHP version on your local LAMP installation

If you’ve installed a test environment locally on your computer (See June’s Joomla Community Magazine article Installing a Test Environment), the best way to install a new version of PHP would be to update your LAMP installation.

New versions of various installers are regularly released that support the latest versions of PHP, and typically you can install the update and your versions will be updated automatically.

  • XAMPP - Linux, Windows and Mac versions available
  • MAMP - Mac and Windows versions available

Troubleshooting Tips

PHP is a server-level application layer. So this means that when something goes wrong, it really goes wrong, and most commonly brings your website down with a number of errors.

Over time I’ve only encountered a handful of errors when switching PHP versions, and the two most common (both which I triggered while creating screenshots for this article) are:

  • 503 Error - Service Unavailable
    A 503 error may occur temporarily while the server changes settings for your account. If it continues to display after a few minutes, revert the version change you made.
  • 502 Error - Bad Gateway
    502 errors are a permanent issue when they occur. Usually, it means that the change you made is not compatible with the settings on the server. I triggered a 502 error when changing the Plesk version, as instead of keeping the “run PHP as” option set to what it was originally set to. Changing the setting to match the original setting cleared the 502 error.

You can find (and contribute) additional troubleshooting tips on the Updating PHP page in JDOCs.

An alternative that is not recommended

Joomla 3.9 will work on PHP 7.2 and above, but as mentioned at the start of the article, you will get a warning message if your PHP version is below the current required version.

Often upgrading PHP may not be done straight away, though I hope you can see how easily it can be done if you’re with a quality hosting company. Joomla administrators may feel uncomfortable when they PHP warning messages, and so there is a way to disable the PHP version check, though upgrading PHP and keeping Joomla also updated should be your preferred path.

Here’s how to disable the PHP Version Check message:

  • Login to the backend of your Joomla website.
  • Go to on Extensions -> Plugins.
  • Search for the plugin titled Quick Icon – PHP Version Check and disable it by clicking on the green checkmark next to it which will unpublish the plugin.
  • Return to your Joomla control panel and the message will now have disappeared.

Further Resources

The variety of available server configurations means that covering every variation in a magazine article is not practical.

To allow for other methods to be documented, a page on JDOCs has been created. Please contribute further methods and troubleshooting tips on the Updating PHP page in JDOCs.


 This article updates the information previously available in one of the Joomla Community Magazine's most visited articles How to upgrade your website PHP version by Parvez Akther from May 2016.

0
Leadership Interview: Jaz Parkyn
The Power of Open Source
 

Comments 5

Already Registered? Login Here
Robert Fairhead on Tuesday, 13 October 2020 02:36
Make a note of the existing settings!

Good article, Patrick. As discussed, "make a note of the existing settings" proved to be the key tip for me because I had settings in 7.2 that weren't selected by default in 7.3. And this resulted in my Joomla website on the shared server environment becoming unavailable (and my "dark side" ones, too).

Thankfully, @Terry provided me with a clue to the problem in a response to my query about the problem on the Joomla Australia forum. I checked his suggested settings against mine in PHP 7.2 and then ensured the settings were identical for 7.3.

All fixed, in Joomla and the "dark side".

^Robertf

0
Good article, Patrick. As discussed, "make a note of the existing settings" proved to be the key tip for me because I had settings in 7.2 that weren't selected by default in 7.3. And this resulted in my Joomla website on the shared server environment becoming unavailable (and my "dark side" ones, too). Thankfully, @Terry provided me with a clue to the problem in a response to my query about the problem on the [url=https://joomla.org.au/forum/q-a-tips-tricks/7322-errors-upgrading-php-to-7-3]Joomla Australia forum[/url]. I checked his suggested settings against mine in PHP 7.2 and then ensured the settings were identical for 7.3. All fixed, in Joomla and the "dark side". :D ^Robertf
Robert Fairhead on Monday, 14 December 2020 02:58
Update to 7.4

Hi Patrick, Akeeba backup in Joomla (and WordPress) started warning me to upgrade from PHP 7.3 to 7.4. Apart from the end of support for 7.3 from 2021, one of the benefits listed was a speed improvement, as per the Joomla warning in your article. I didn't notice much of an improvement from 7.2 to 7.3, BUT from 7.3 to 7.4 is AMAZING! Either that or my caching is finally working!

0
Hi Patrick, Akeeba backup in Joomla (and WordPress) started warning me to upgrade from PHP 7.3 to 7.4. Apart from the end of support for 7.3 from 2021, one of the benefits listed was a speed improvement, as per the Joomla warning in your article. I didn't notice much of an improvement from 7.2 to 7.3, BUT from 7.3 to 7.4 is AMAZING! Either that or my caching is finally working! :D
Stephen Leach on Tuesday, 12 January 2021 14:06
Who do I approach for help on this please?

I've read your article as I get the warning message. My Joomla site [ in development] is hosted on my Synology NAS. The .htaccess file in my Joomla Root folder doesn't have an AddHandler script within it to amend.
What am I missing here?
Thanks

0
I've read your article as I get the warning message. My Joomla site [ in development] is hosted on my Synology NAS. The .htaccess file in my Joomla Root folder doesn't have an AddHandler script within it to amend. What am I missing here? Thanks
Patrick Jackson on Tuesday, 12 January 2021 23:52
Upgrading PHP on a NAS

Stephen,

Upgrading PHP on a NAS is NAS specific, so for the Synology NAS, here's a guide I found: https://skdavis.net/viewtopic.php?t=161

Once you've installed the PHP version (example shows 7.2, but 7.3 is available), set Web Station to use that version as the default. The warnings should go, and you won't need to make the change to the .htaccess.

Patrick

0
Stephen, Upgrading PHP on a NAS is NAS specific, so for the Synology NAS, here's a guide I found: https://skdavis.net/viewtopic.php?t=161 Once you've installed the PHP version (example shows 7.2, but 7.3 is available), set Web Station to use that version as the default. The warnings should go, and you won't need to make the change to the .htaccess. Patrick
Stephen Leach on Thursday, 14 January 2021 09:55
Thank you

Thanks for your response; I'll give it a try.
Stephen

0
Thanks for your response; I'll give it a try. Stephen

By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/