cPanel with the PHP selector shows WordPress Error & ldquo; the PHP installation seems to be missing the MySQL extension that is required by WordPress & rdquo;

advertisements

After an upgrade of MySQL to use MariaDB 10, multiple sites on my CloudLinux cPanel server are just white screens with Error: Your PHP installation appears to be missing the MySQL extension which is required by WordPress

I can choose the PHP version per account, but selecting any from 5.3 up to 5.6 still doesn't work.

Nothing is working, rebuilding Apache and PHP using /scripts/easyapache/ is not working, and running <?php echo phpinfo(); ?> on the failing sites shows there is no mysql or mysqli extension.

How can this be fixed?


This may NOT require big rebuilds or reinstallation of PHP/MySQL if you are running MySQL/MariaDB on your cPanel server - which is quite likely if you are running 64-bit CloudLinux.

It might just be broken symlinks to the modules.

If you log into WHM and search for "MariaDB" you may find an option "MySQL/MariaDB Upgrade" - this means you are using it. Alternatively you can just ask your host if MySQL/MariaDB is the database management system.

If you are using MariaDB, an upgrade may have broken symlinks to mysql.so, mysqli.so and pdo_mysql.so.

Only attempt the following if you have root access via the command line and know what you are doing - otherwise ask your host to do it.

Create a file called info.php in the web root of your broken site, with the following code:

<?php
    $inipath = php_ini_loaded_file();

    if ($inipath)
    {
        echo 'Loaded php.ini: ' . $inipath;
    } else
    {
        echo "No php.ini - MariaDB symlinks are NOT the problem";
    }
?>

This will give you the path to the php.ini file of PHP build you are using when you navigate to http://www.yoursite.com/info.php.

In my case it showed /opt/alt/php55/etc/php.ini

This is PHP 5.5 which has been selected via the PHP selector in cPanel. The first part of this: /opt/alt/php55/ shows where we need to look in the next step.

Now, log in via the command line and run:

cd /opt/alt/php55/usr/lib64/php/modules
ls -la

Look down the list and see if you can find something like:

mysql.so -> /opt/alt/php55/etc/mysql10/mysql.so

If what appears between /etc/****/mysql.so is not mariadb10 (or whatever version of MariaDB you are running) then you need to rebuild the symlinks.

unlink mysql.so
unlink mysqli.so
unlink pdo_mysql.so

ln -s /opt/alt/php55/etc/mariadb10/mysql.so /opt/alt/php55/usr/lib64/php/modules/mysql.so
ln -s /opt/alt/php53/etc/mariadb10/mysqli.so /opt/alt/php55/usr/lib64/php/modules/mysqli.so
ln -s /opt/alt/php53/etc/mariadb10/pdo_mysql.so /opt/alt/php55/usr/lib64/php/modules/pdo_mysql.so

Then you may need to do the same for other PHP versions available via the PHP selector. In my case this involved also repairing:

/opt/alt/php53/usr/lib64/php/modules
/opt/alt/php54/usr/lib64/php/modules
/opt/alt/php56/usr/lib64/php/modules

It was a complete horror story, but very easily fixed in the end (after rebuilds and other dead-end avenues).