Update PHP in the year of 2021

I saw a notification to update PHP on the WordPress Dashboard of this blog.

Update PHP notification on WordPress dashboard

I saw in the server’s Control Panel that PHP has been setup to version 7.3.

MultiPHPManager

I then saw the Requirements page on the wordpress.org site. The minimum PHP version recommended by the wordpress.org website today is version 7.4.

As mentioned by the wordpress.org site, PHP is the coding language WordPress is built on, and its version is set at the server-level by your hosting company. That means keeping PHP up-to-date is just as important. That will make websites safer and more quickly accessible.

I recommend backing up your WordPress site before updating PHP. Backup will let you revert your site to how it is right now in the event anything goes wrong. There are plenty of free backup plugins available, so if you don’t have a backup solution already – use one of these. Remember, if there is a problem after updating PHP and you need to restore the backup, then the PHP version must be reverted to the version when the backup was created.

I decided not to backup because I believe I do not need that (I don’t recommend you follow my steps not to do backup). I immediately updated WordPress to version 5.6.2, updated plugins and themes.
I saw some errors when updating plugins, I noticed the error from the Jetpack plugin. I ignored it because, after I saw the website, no problem appeared on the front end.

I then updated PHP from MultiPHP Manager on the server control panel. At first, I only updated my blog because that’s where the notification for PHP updates appeared on the Dashboard, but this had no effect so I decided to update everything, the blog and the main site. I implemented PHP version 7.4 and refreshed the sites to check if the update took effect

It turned out that there was an unexpected error, like the attached screenshot.

Update PHP error missing MySQL extension

After checking the error statement, it was preceded by an error when updating plugins, Jetpack raises the following error.

Warning: Use of undefined constant WP_CONTENT_DIR - assumed 'WP_CONTENT_DIR' (this will throw an Error in a future version of PHP) in

The error is caused by PHP handler entries like the following as an example,

# Use PHP71 as default
AddHandler application/x-httpd-php71 .php
<IfModule mod_suphp.c>
    suPHP_ConfigPath /opt/php71/lib
</IfModule>
#Use PHPedge as default
AddHandler application/x-httpd-php-edge .php
<IfModule mod_suphp.c>
    suPHP_ConfigPath /opt/phpedge/lib
</IfModule>

I checked the .htaccess file on my sites, the blog and the main site, but there are no such PHP handler entries. Then I checked the .htaccess file on my home user. As it turns out, PHP handler entries are there. To disable the PHP handler that you don’t want, you can add a “#” at the beginning of each line. I saved this change. Pull up your site to check if the error is already gone.

My website is currently using PHP version 7.4

If you have any questions, please comment or send a question via email.

Note: This fix requires you to be comfortable navigating the File Manager and modifying files.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: