0
votes

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:
- sudo apt-get update & sudo apt-get -y install php-mysql
- sudo update-alternatives --set php /usr/bin/php7.2
* while checking if the last one worked with wp --info, I also got the following warning:

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?

Thanks a lot in advance.

4
It didn't work either :-( apt-get install php-mysqli/mysqlnd redirects to installing php-mysql which, apparently is already at its newest versionMartaKa
I've just noticed the typo in Ubuntu version, it should be Ubuntu 18.04.2MartaKa

4 Answers

10
votes

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
1
votes

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.

1
votes

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
0
votes

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.

Thank you all for your help, I really appreciate your input :-)