Hostgator, PHP, WordPress and .htaccess

The PHP Selector in the Hostgator cPanel has been replaced with the MultiPHP Manager. I’m not sure when the change happened – functionally, MultiPHP Manager does what PHP Selector did – edits the Apache .htaccess configuration for you, allowing you to easily change the active PHP version.

I tried to use it when WordPress was complaining about an outdated PHP version, and it didn’t really work how I expected it to.

The MultiPHP Manager is available in the Hostgator cPanel.

The tool shows you the default PHP version (PHP 5.4) and has a section for applying PHP versions to specific domains.

Hostgator’s supported PHP versions are 7.0, 7.1, 7.2, and 7.3 – though PHP 7.4 is the current latest-and-greatest version.

Hostgator PHP versions in the new MultiPHP Manager

The “ea-” prefix is the cPanel EasyApache versions of PHP. AFAIK they are functionally identical to your “vanilla” PHP versions. Details about EasyApache be found here.

Hostgator is a very popular hosting provider for WordPress. If you haven’t manually updated your PHP version (by editing the .htaccess) or used one of the cPanel controls, the WordPress dashboard will complain…

I used the tool to update my domain’s PHP version to 7.3. It successfully “took” but I was now getting an error about the PHP MySQL extension and a path being invalid.

The trick to fixing this error was to remove any sections in the domain folder’s .htaccess file…

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

Or this…

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

I removed those sections, but WordPress still gave an error.

The trick is that there’s a .htaccess file in the root folder too, that seems to override any sub-folder below it – edit THAT file’s sections to not include old PHP handlers, and you’ll be up and running again.