Without more information I can only describe general causes:
php7.0-mysql
package is not installed, to fix run sudo apt-get install php-mysql
mysqli
module got somehow disabled, to fix run phpenmod mysqli
- You are using different web SAPI PHP version than you have PHP CLI, f.e. you might have installed
libapache2-mod-php5.6
with php7.0-cli
- Your Apache 2.x configuration contains different PHP FPM version (f.e.
php5.6-fpm
package) and Apache2 module (f.e. libapache2-mod-php7.0
). Disable the FPM by running: a2disconf php5.5-fpm
.
- The web SAPI, you are using for web has different configuration file and thus mysqli module is not loaded, to fix add
extension=mysqli.so
to this custom configuration file
- something else is broken and you should lookup for log messages indicating what's broken
To get more diagnostics:
run `php -r 'phpinfo();' and check the output for MySQL references:
$ php -r 'phpinfo();' | grep -i mysqli
/etc/php/5.6/cli/conf.d/20-mysqli.ini,
mysqli
MysqlI Support => enabled
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqli.rollback_on_cached_plink => Off => Off
API Extensions => mysql,mysqli,pdo_mysql
Do the same with the web, create a simple page with just `' and check the output for MySQLI module
After further looking into the issue, we found out, that there was a mix of PHP 5.5 and PHP 7.0 in the system that probably confused Apache2. As a general recommendation I would definitely recommend start with one PHP version to debug and purge the other(s).
To completely purge a specific PHP version, you can purge phpX.Y-common
package that will pull all the other reverse dependencies:
Example:
apt-get purge php5.5-common # to remove PHP 5.5
apt-get purge php5.6-common # to remove PHP 5.6
apt-get purge php7.0-common # to remove PHP 7.0
# and to remove old php5 packages:
apt-get purge php5-common # to remove old PHP 5.x packages
sudo apt-get install php-mysql; sudo service apache2 restart
.