Cpanel and WHM

(Resolved) Fix PHP / MultiPHP Version Upgrade Error in WHM/cPanel

Upgrading your PHP version may be required when you update WordPress to the latest version or update related plugins. My firewall tool recommended that I upgrade WordPress, which I did, and then I saw the warning message below and the website was down. I was upgrading PHP from version 5.6 to 7.4 using the MultiPHP Manager in cPanel.

Warning: Use of undefined constant WP_CONTENT_DIR – assumed ‘WP_CONTENT_DIR’ (this will throw an Error in a future version of PHP) in /home/XXXXX/public_html/wp-includes/load.php on line 115

Let me get straight to the point. The error was caused by the auto-generated PHP handler (version 7.4) in .htaccess conflicting with another PHP handler (version 5.6) that was running at the same time on the server.

My old PHP handler looked like this:

# Use PHP56 as default
AddHandler application/x-httpd-php56 .php
<IfModule mod_suphp.c>
    suPHP_ConfigPath /opt/php56/lib
</IfModule>

My new PHP handler looks like this:

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

In my case, the upgrade in MultiPHP Manager generated the 7.4 PHP handler in the public_html folder, while my old PHP 5.6 handler already existed in the folder above public_html, which is above the root directory. That was what caused the error. You can’t run multiple PHP handlers for a single website.

My solution was simply to remove (or rename, if you don’t want to delete the file) the .htaccess file (PHP 5.6) from one level above the root directory. Now it works like a charm!

Leave a Comment

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