MartaKa
MartaKa

Reputation: 41

Error "Your php installation appears to be missing the mysql extension which is required by wordpress" on Ubuntu 18.0.4. and PHP 7.2

I have recently updated my Ubuntu version from 16.04 to 18.0.4 with PHP version upgraded to 7.2. I haven't been able to log on to my Wordpress websites due to the following error:

Your php installation appears to be missing the mysql extension which is required by Wordpress

What I have tried:

PHP Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: /usr/lib/php/20170718/mysqli (/usr/lib/php/20170718/mysqli: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/mysqli.so (/usr/lib/php/20170718/mysqli.so: undefined symbol: mysqlnd_global_stats)) in Unknown on line 0

These were in fact missing from php.ini. I added both

extension=/usr/lib/php/20170718/mysqli
and
extension=/usr/lib/php/20170718/mysqlnd.

The PHP warning disappeared, but the MySQL extension still seems to be missing.

The php.ini file is located at /etc/php/7.2/cli/php.ini. I restarted apache after each change I made.

Would you have any other solution that might work?

Upvotes: 3

Views: 20654

Answers (8)

Adeel Raza Azeemi
Adeel Raza Azeemi

Reputation: 823

Adding to the previous answers; please remember that php version on the command line can be different than the PHP version of Apache. So instead of using the command line to find what my php version is; create an info.php in the main html or www folder. and in it echo phpinfo(); to find what actually your PHP version is in Apache.

Upvotes: 0

PyMatFlow
PyMatFlow

Reputation: 478

If you are using Apache Ubuntu, Update your PHP version to 8.1 solve your problem

sudo apt update && apt install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update && sudo apt install -y php8.1
php -v

sudo apt-get install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath

sudo apt-get install -y php8.1-fpm

sudo apt install php libapache2-mod-php php-mysql

Upvotes: 0

ravi singhal
ravi singhal

Reputation: 39

For AWS EC2 ubuntu Nginx Server

1.First check which version install in your pc by using this command :

php -version or which php

2.for example if you getting 7.4.33 run like this (based on php version )

apt install php7.4-mysql

3.After install MySql restart apache server

sudo systemctl restart apache2

Upvotes: 1

MartaKa
MartaKa

Reputation: 41

I finally managed to find the solution to my problem.

This particular project runs on PHP 7.0., so I need to switch to the older version of PHP in order to work on it.

Upvotes: 0

Khaim Leroy
Khaim Leroy

Reputation: 21

A combination of the solutions above helped me.

After updating I couldn't reach my sites anymore, so I altered the code like this:

sudo a2dismod php*
sudo a2enmod php8.0
sudo systemctl restart apache2

Upvotes: 2

Jignesh Joisar
Jignesh Joisar

Reputation: 15175

1.First check which version install in your pc by using this command :

php  -v

2.for example if you getting 7.2 run like this (based on php version )

sudo apt-get install php7.2-common php7.2-mysql

3.After install MySql restart apache server

sudo service apache2 restart

Upvotes: 21

The Billionaire Guy
The Billionaire Guy

Reputation: 3552

i solved this type of error in my .htaccess using the below code on a shared server that uses cpanel

# END WordPress
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php71” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php71 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

Upvotes: 1

dntrplytch
dntrplytch

Reputation: 159

I am adding my answer here - though the circumstances are slightly different. I upgraded my Debian installation - and in the process php was upgraded from php 5 to php 7.0

It turns out that apache2 was still loading the php5 module and not the php7.0 module.

I needed to run the below:

  sudo a2dismod php5
  sudo a2enmod php7.0
  sudo systemctl restart apache2

Subsequently, my web pages loaded up.

Upvotes: 2

Related Questions