If you recently opened your WordPress dashboard, you may be seen an new banner that warns you about a required PHP update. The message says the following:
WordPress has detected that your site is running on an outdated version of PHP.WordPress.org banner on the Dashboard page
What is PHP and how does it affect my site?
PHP is the programming language we use to build and maintain WordPress. Newer versions of PHP are both faster and more secure, so updating will have a positive effect on your site’s performance.
Learn more about updating PHP
The WordPress developers have recently agreed among them that they want to increase the minimum version of PHP. So if you server is still running an older version of PHP, you risk that your WordPress website will no longer work. More concretely, it’s likely that you are still running PHP 5.6 (or below).
Depending on how you have set up WordPress, there are a number of things you should do.
You are using a shared hosting environment
In case you use a shared hosting environment, it will be up to the hosting provider to make sure their servers are upgraded to the latest (or a more recent) version of PHP.
You will need to contact your hosting provider so that they can upgrade the PHP version for you. It’s likely you are not the only one who sees the error banner in WordPress to upgrade, but it’s always good to take action.
Another possibility is that the hosting provider is running multiple PHP versions at the same time. If this is the case, you can explicitly specify which version you want to use. For example, if you want to specify that you want to use PHP version 7.2, open the .htaccess file in the root of the domain and paste the following line at the top of that file:
AddHandler application/x-httpd-php72 .php
In case your WordPress installation is hosted at example.com/wordpress or example.com/blog, you could also opt to create a separate .htaccess file (with the same contents as shown above) so that only for that folder PHP 7.2 will be used.
You manage your server yourself (e.g. VPS, reseller)
Managing your server gives you a lot of flexibility. However, when it comes to upgrading software, it means a bit more work as you have to do everything yourself to keep up with the latest updates to ensure security and speed.
First of all, you may wonder: ‘what version of PHP is my server running?’. It’s easy to uncover that information. Create a file on your server with the name info.php and with contents:
<?php phpinfo(); ?>
Then, browse to the file in your web browser and check the version you are currently running. It’s likely the version will be lower then let’s say version PHP 7.3. In this case, you should upgrade in order to profit from the increased speed and security of the newest PHP version.
In this example, let’s assume version 7.3 is the latest version and you want to upgrade to that version on a Linux server.
Open an SSH session and upgrade your PHP version with this command:
sudo apt-get install php 7.3 php7.3-common
You may need to restart PHP in order for changes to take effect.