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

If you are a WordPress user and finding the issue that “Your PHP installation appears to be missing the MYSQL extension which is required by WordPress”. This might be a very hectic error to deal with. Being a webmaster, when I faced this issue, I posted this issue in best of the forums on the internet but when I did not get any solution I finally decided to do some R&D. It took me 3 days to do R&D and resolve this issue.

Once the issue was resolved, I decided to share the solution of this issue with the people who are using Ubuntu or CentOS, php5-cli, php5-cgi, php5-fpm and using NGINX server. The solution might vary as per the services you are using to run your website. But still, it can help you to at least get some ideas.

Here’s the final solution:

In order to deploy PHP applications, you will need to implement “PHP-FastCGI” solution to allow NGINX to properly serve web pages.

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

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

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

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

Now you need to remove and reinstall the NGINX using the following command:

sudo apt-get remove nginx # Removes all but config files.
sudo apt-get purge nginx # Removes everything.
sudo apt-get autoremove # Once using both of the above commands, use this command. This will remove all the dependencies used by NGINX which are no longer required.

Now, reinstall NGINX server:

sudo apt-get install nginx

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

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

Similarly, create an another configuration file for an another website and repeat this step for all the other websites you want to host.

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

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

Configuration for Website1.com

server {

listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/website1.com/public_html;

index index.php;
# Make site accessible from http://localhost/

server_name websitevidya.com www.website1.com *.website1.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 Website2.com

server {
listen 80;
listen [::]:80;
root /var/www/website2.com/public_html;

index index.php;
# Make site accessible from http://localhost/

server_name websitevidya.com www.website2.com *.website2.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 directory to sites-enabled directory. Do this for each of this config files you have just created.

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, we will remove the default config file from the sites-enabled directory.

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

Now we need to restart NGINX and PHP5-fpm:

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

Run the following command to install the MySQL server and packages that are required for 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. If still this issue persists, put your problem in the comment section below.

Read more about Nginx.

If you have any other solution, do share it with us. It will highly be appreciated.

Your PHP installation appears to be missing the MySQL extension

If you are a WordPress user and finding the issue that Your PHP installation appears to be missing the MYSQL extension which is required by WordPress”.

Send this to a friend