Website Vidya
DeploymentStep-by-Step Guide

Your PHP installation appears to be missing the MySQL extension which is required by WordPress

If you are a WordPress user and getting an error that says "Your PHP installation appears to be missing the MYSQL extension which is required by WordPress", then this might be very frustrating to deal with. Being a webmaster, I faced the sa...

RR
Website Vidya TeamLead Systems Educator
Published:
6 min read
Your PHP installation appears to be missing the MySQL extension which is required by WordPress
AI Executive SummaryCORE CIS AI

6 min read

If you are a WordPress user and getting an error that says "Your PHP installation appears to be missing the MYSQL extension which is required by WordPress", then this might be very frustrating to deal with. Being a webmaster, I faced the sa...

Key Highlights
  • Steps to Fix "Your PHP installation appears to be missing the MySQL extension which is required by WordPress"
  • Other Error Fixes
  • Wrap Up
Grounded in full engineering runbookCORE CIS Ai Engine

If you are a WordPress user and getting an error that says "Your PHP installation appears to be missing the MYSQL extension which is required by WordPress", then this might be very frustrating to deal with.

Being a webmaster, I faced the same issue with my website. I searched online for a solution, posted in the best of the forums on the internet but did not get any accurate solution to fix my problem.

Finally, I took the initiative to delve into the matter and conduct some in-depth research and experimentation to rectify the error.

Once the issue was resolved, I decided to share the solution to this issue with the people who are using Ubuntu or CentOS, php5-cli, php5-cgi, php5-fpm, and using the NGINX server. The solution might vary as per the services you are using to run your website.

The error message you're seeing, "Your PHP installation appears to be missing the MySQL extension which is required by WordPress," indicates that the MySQL extension is not enabled in your PHP configuration, and WordPress requires it to function properly.

The MySQL extension is used by PHP to interact with MySQL databases, which are commonly used to store and retrieve data for applications like WordPress.

Note: This solution is also valid for php7.0-cli, php7.0-cgi, php7.0-fpm , and php8.1-fpm.

Steps to Fix "Your PHP installation appears to be missing the MySQL extension which is required by WordPress"

Before proceeding with the detailed steps, consider implementing the following tweaks:

Check PHP Version: Make sure you are using a version of PHP that is compatible with the MySQL extension. WordPress generally supports PHP versions 5.6 and above. However, it's recommended to use a more recent version for security and performance reasons.

Enable MySQL Extension: Depending on your server environment and how PHP is configured, you might need to enable the MySQL extension. You can do this by modifying the PHP configuration file (php.ini). Look for the following line and remove the semicolon (;) to uncomment it:

;extension=mysqli

Change it to:

extension=mysqli

This will enable the MySQL extension. Save the php.ini file and restart your web server (e.g., Apache or Nginx) for the changes to take effect.

To deploy PHP applications, "PHP-FastCGI" is implemented which allows NGINX to serve web pages properly.

Check for Alternative Extensions: In more recent versions of PHP, the mysql extension has been deprecated in favor of the mysqli (MySQL Improved) extension and the PDO extension. It's recommended to use mysqli or PDO for better security and functionality.

If your WordPress installation or themes/plugins you're using are relying on the deprecated mysql extension, you might need to update them to use mysqli or PDO instead.

Update WordPress and Plugins: If you're using an outdated version of WordPress or plugins, they might be using deprecated features. Make sure to update WordPress core and all plugins to their latest versions to ensure compatibility with modern PHP versions.

If you don't have access to your admin dashboard, use FTP to delete the outdated themes and plugins and upload the latest version.

To manage WordPress Plugins, check How to Install WordPress Plugins: 2 Easy Steps.

Server Compatibility: Prioritize confirming that your server environment aligns with the essential prerequisites for running WordPress smoothly, alongside the selected PHP version. Refer to the official WordPress documentation to obtain precise insights into the specific requirements that need to be met.

Step 1: Remove and Reinstall PHP-FastCGI

First of all, you need to remove some of the PHP services by running the following code:

sudo apt-get remove php5-cli php5-cgi php5-fpm

Once you remove these services, reinstall them by running the following install command:

sudo apt-get install php5-cli php5-cgi php5-fpm

Step 2: Remove and Reinstall NGINX Web Server

In this step, remove and reinstall the NGINX Server by running:

sudo apt-get remove nginx # Removes all but config files.
sudo apt-get purge nginx # Removes everything.

Once using both of the above commands, run:

sudo apt-get autoremove

This will remove all the dependencies used by NGINX that are no longer required.

Now, reinstall the NGINX server:

sudo apt-get install nginx

Step 3: Configure Nginx

Now, configure NGINX for your websites. If you are hosting more than one website on a single server, create a separate config file for each of your websites.

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example1.com

Similarly, create another configuration file for another website and repeat this step for all the other websites.

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example2.com

Now, open each configuration file one by one, search for the following configuration and update them:

Configuration for example1.com

 server {
 listen 80 default_server;
 listen [::]:80 default_server ipv6only=on;
 root /var/www/example1.com/public_html;
 index index.php;
 Make site accessible from http://localhost/
 server_name example1.com www.example1.com *.example1.com;
 location / {
 First attempt to serve request as file, then
 as directory, then fall back to displaying a 404.
 try_files $uri $uri/ /index.php;
 Uncomment to enable naxsi on this location
 include /etc/nginx/naxsi.rules
 }
 location ~ .php$ {
 fastcgi_split_path_info ^(.+.php)(/.+)$;
 # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
 #
 # With php5-cgi alone:
 fastcgi_pass 127.0.0.1:9000;
 # With php5-fpm:
 fastcgi_pass unix:/var/run/php5-fpm.sock;
 fastcgi_index index.php;
 include fastcgi_params;
 }

Configuration for example2.com

 server {
 listen 80;
 listen [::]:80;
 root /var/www/example2.com/public_html;
 index index.php;
 Make site accessible from http://localhost/
 server_name example2.com www.example2.com *.example2.com;
 location / {
 First attempt to serve request as file, then
 as directory, then fall back to displaying a 404.
 try_files $uri $uri/ /index.php;
 Uncomment to enable naxsi on this location
 include /etc/nginx/naxsi.rules
 }
 location ~ .php$ {
 fastcgi_split_path_info ^(.+.php)(/.+)$;
 # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
 #
 # With php5-cgi alone:
 fastcgi_pass 127.0.0.1:9000;
 # With php5-fpm:
 fastcgi_pass unix:/var/run/php5-fpm.sock;
 fastcgi_index index.php;
 include fastcgi_params;
 } 

Once you complete the configuration of each of your websites, you need to move these files from the sites-available to the sites-enabled directory. Do this for each of the config files you have just created by running the following command:

For website1.com

sudo ln -s /etc/nginx/sites-available/website1.com /etc/nginx/sites-enabled/

For website2.com

sudo ln -s /etc/nginx/sites-available/website2.com /etc/nginx/sites-enabled/

Then, remove the default NGINX configuration file from the sites-enabled directory by running the following command:

sudo rm /etc/nginx/sites-enabled/default

Now, restart NGINX and PHP5-fpm:

service php5-fpm restart
/etc/init.d/nginx restart

Step 4: Install MySQL Server & Packages

Run the following command to install the MySQL server and the packages required for the database to support PHP (You do not need to purge the MySQL Server):

sudo apt-get install mysql-server php5-mysql

Finally, restart php5-fpm:

service php5-fpm restart

That’s it! It should solve the issue.

If you're using a web hosting service, they might have specific configurations or limitations in place. Contact your hosting provider's support if you're unsure about enabling the MySQL extension.

Other Error Fixes

I would also advise you to set up and keep an eye on error reporting for PHP and NGINX. This will help you understand the issue more accurately.

Wrap Up

Incorporating these steps and insights should pave the way for resolving the issue at hand—tackling the "Your PHP installation appears to be missing the MySQL extension which is required by WordPress."

By adhering to best practices, verifying server compatibility, seeking hosting provider guidance, and staying current with updates, you're well-equipped to reinstate full functionality in your WordPress environment.

Remember that addressing such challenges systematically not only resolves the immediate concern but also contributes to an optimized and secure WordPress experience.

Should you encounter any further questions or obstacles, feel free to seek additional support.

Written by

Website Vidya Team

Technology educator and researcher at Website Vidya.

Discussion

0
Share your thoughts, ask a question, or suggest a tip...
Write →

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Deployment•

How to Install PDO Extension in PHP

PHP Data Objects (PDO) is one of the most important extensions in PHP for working with databases in a secure, consistent, and modern way. If you are building dynamic websites, APIs, CMS platforms, or enterprise applications, PDO is not opti...

RR
Rajesh Rai
Read More
Deployment•

How to Install PHPMyAdmin on Ubuntu: 4 Simple Steps

If you’re working with MySQL or MariaDB on Ubuntu, managing databases purely from the command line can quickly feel overwhelming. That’s where phpMyAdmin comes in. PHPMyAdmin is a web-based application that provides a Graphical User Interfa...

RR
Rajesh Rai
Read More
Deployment•

25 Best Linux Commands Every Sysadmin Should Know

If you’ve spent any time managing Linux servers, you already know this truth: the command line is not optional. It’s where real troubleshooting happens, where performance issues are understood, and where outages are prevented before users e...

RR
Rajesh Rai
Read More
Deployment•

How to Fix Snapd Consuming High CPU / RAM on Linux

If you’ve ever opened your system monitor and noticed snapd quietly eating up your CPU or RAM, you’re not alone. Many Linux users—especially on Ubuntu and Ubuntu-based distributions—eventually run into this issue and wonder what’s going on ...

RR
Rajesh Rai
Read More
Deployment•

How to Fix Broken Packages in Ubuntu: 7 Simple Ways

If you’ve been using Ubuntu for a while, chances are you’ve run into package-related issues at least once. A failed update, an interrupted installation, or conflicting dependencies can easily leave your system in a messy state. When that ha...

RR
Rajesh Rai
Read More