The error "PHP installation appears to be missing the MySQL extension" commonly occurs when setting up WordPress on a new Linux VPS. This happens because the MySQL extension for PHP is not installed by default on many operating systems. This guide shows you how to install the required extension and complete your WordPress installation successfully.
How to Fix the Missing MySQL Extension
-
Step 1: Connect via SSH and check PHP version
Connect to your Linux VPS using SSH and verify which PHP version you are running:
php -vAlternatively, create a file named
info.phpin yourpublic_htmldirectory with this content:<?php phpinfo(); ?>Then access the file through your web browser to see detailed PHP information.
-
Step 2: Install MySQL extension for Ubuntu/Debian
If you are running Ubuntu or Debian with PHP 7.x, execute these commands:
apt-get update apt-get install php7.0-mysqlFor PHP 5.x, use:
apt-get update apt-get install php-mysqlTo search for all available MySQL-related packages:
apt-cache search mysql -
Step 3: Install MySQL extension for CentOS/RHEL
If you are running CentOS or RHEL with PHP 7.x, execute these commands:
yum update yum install php70w-mysqlFor PHP 5.x, use:
yum update yum install php-mysqlTo search for all available MySQL-related packages:
yum search mysql -
Step 4: Restart your web server
For the changes to take effect, restart the appropriate service:
If using Apache:
systemctl restart apache2If using Nginx with PHP-FPM:
systemctl restart php-fpm -
Step 5: Continue WordPress installation
Return to your WordPress setup in the web browser. If the MySQL extension was installed correctly, the error message will no longer appear and you can proceed with the WordPress installation.