“PHP installation appears to be missing the MySQL extension” is a common error in WordPress, if you are setting up a WordPress CMS on a new Linux VPS. You get the message of missing MySQL extension because this extension isn’t by default available in many operating systems. In this tutorial, you will learn to fix this problem and complete the WordPress installation successfully.
Don’t get panic if you get the missing a PHP extension error. If you see the below message on your screen while accessing the WordPress installation via web browser, then you are one of the many WordPress users that face the same problem:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Follow the below steps to solve this error:
Connect via SSH and Check the PHP Version
Ensure that you have a SSH access to the server. Using SSH, connect to your Linux VPS and check the PHP version that you are currently using:
php -v
Create Info.php File
Alternate way of checking the PHP version is by creating a simple info.php file in your public_html directory with the below content:
<?php phpinfo(); ?>
After creating the file, open your choice of web browser and access the file.
Update the Required Packages
In case you are running an Ubuntu VPS and PHP 7, then execute the following commands:
apt-get update apt-get install php7.0-mysql
Restart the Web Server
Next, you will need to restart your Apache service for the changes to take effect, or in case you are using Nginx + PHP-FPM, then you will need to restart the PHP-FPM service.
Update PHP
If you are running PHP 5, run the below commands:
apt-get update apt-get install php-mysql
Then you should restart the appropriate service for the changes to take effect.
Search All the Available Packages Containing MySQL
In order to search all the available packages that contain mysql, you can use the below command:
apt-cache search mysql
Or, if you are running a CentOS VPS that contains PHP 7 installed on the server, then execute the below commands to fix the error:
yum update yum install php70w-mysql
Restart Apache
You will need to restart Apache or the PHP-FPM service if you are using Nginx + PHP-FPM as a web server.
If PHP 5 is installed on your CentOS server, execute the following commands:
yum update yum install php-mysql
Then you should restart the appropriate service for the changes to take effect.
In order to search all the available packages containing mysql, you can execute the following command:
yum search mysql
After installing the MySQL extension for PHP, you can switch back to your WordPress setup. If the installation goes OK, the message about the missing MySQL extension won’t appear. You can then continue with your WordPress setup.