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 best of the forums on the internet but did not get any accurate solution to fix my problem.
I finally started exploring things and did some R&D to fix the error.
Once the issue was resolved, I decided to share the solution of this issue with the people who are using Ubuntu or CentOSphp5-cli
php5-cgi
php5-fpm
and using NGINX server. The solution might vary as per the services you are using to run your website.
Note: This solution is also valid php7.0-cli
php7.0-cgi
php7.0-fpm
But still, it can help you to at least get some ideas.
Steps to Fix “Your PHP installation appears to be missing the MySQL extension which is required by WordPress”
In order to deploy PHP applications, “PHP-FastCGI” is implemented that allows NGINX to serve web pages properly.
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 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 sites-available to sites-enabled directory. Do this for each of this 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 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.
Other Error Fixes
- Error Establishing a Database Connection in WordPress Fix
- 4 Simple Ways to Fix 502 Bad Gateway Nginx Error in Ubuntu
- 5 Simple Steps to Fix 504 Gateway Timeout Nginx Error
- PHP5-FPM 502 Bad Gateway Error (connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory)
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.
I hope this will help you resolve “Your PHP installation appears to be missing the MySQL extension which is required by WordPress”.
If this issue persists, put your problem in the comment section below.