
PHP version needs to be updated everywhere. Constantly. It’s a never ending process. When I did it in my WordPress site at HostGator cPanel, I got an error about a missing MySQL extension. Here’s how I solved it.
I did a major shift from PHP 5.6 to 7.4. And immediately my site broke and throw what follows.
The error presented after applying the PHP change in cPanel for my domain and WordPress site:
Warning: Use of undefined constant WP_CONTENT_DIR – assumed ‘WP_CONTENT_DIR’ (this will throw an Error in a future version of PHP) in /home2/****/public_html/wp-includes/load.php on line 115
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Deprecated: Directive ‘allow_url_include’ is deprecated in Unknown on line 0
The solution is simply editing the .htaccess file
HostGator’s instructions clearly say that the .htaccess file is to blame. So you log in to cPanel, access your files via File Manager and boom, you search and search and you cannot find the .htaccess file! Maybe you scratched your head a bit thinking and doubting your intelligence. But don’t worry, here are the steps that may help:
- Log in to your site’s cPanel
- Open File Manager
- On the top-right corner click Settings and tick “Show Hidden Files (dotfiles)”
- Click Save
- Go to your website root folder (normally public_html) and click once on the .htaccess file and Download a copy of it to your computer before making any changes to it
- Then open it to edit it – to do this click on .htaccess once and then click the Edit button
- There may be references of older PHP versions in this file. Check for them. I believe HostGator’s PHP version change already made all the changes automatically in my .htaccess and this file looked perfectly normal to me. So the error did not come from this .htaccess. For reference here are the contents I had for my WordPress root folder .htacess:# BEGIN WordPress
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg “access plus 6 hours”
ExpiresByType image/jpeg “access plus 6 hours”
ExpiresByType image/gif “access plus 6 hours”
ExpiresByType image/png “access plus 6 hours”
ExpiresByType text/css “access plus 6 hours”
ExpiresByType application/pdf “access plus 1 week”
ExpiresByType text/javascript “access plus 6 hours”
ExpiresByType text/html “access plus 5 minutes”
ExpiresByType image/x-icon “access plus 1 year”
ExpiresDefault “access plus 3 hours”
</IfModule>
<ifModule mod_headers.c>
Header set X-Endurance-Cache-Level “2”
</ifModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule># END WordPress# 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 - But the problem was still there – so next step was to check a folder one step up for any .htaccess files present in there.
- So you may see that there indeed is a .htaccess file there. In my case the contents were:
Use PHP71 as default
AddHandler application/x-httpd-php71 .php
<IfModule mod_suphp.c>
suPHP_ConfigPath /opt/php71/lib
</IfModule> - I commented it all out by adding an # in front of each line. Then I added new part under it all:
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>So this file looked like follows finally:
- Saved the file and my error about a missing MySQL extension and all was gone.
So all in all the most important value that you may find was the hint that .htaccess files are hidden and the visibility needs to be enabled in HostGator web based file manager.
Hope this helps.
Articles that helped to solve the issue:
https://www.hostgator.com/help/article/how-to-fix-error-after-multiphp-update
https://www.betterhostreview.com/fix-missing-wordpress-mysql-extension-error-hostgator.html