0

Short update to the problem below:

I created a small script

<?php
if (!extension_loaded('mysqli'))  {
    dl('mysqli.so');
}
?>

To test my problem further. The strange thing is: when I execute this as root, it works properly, means the mysqli-extension is available. When I execute this as any other user, it returns

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

The related user is already member of the group MySQL - so what else could cause this behaviour?


When calling a PHP script which makes use of mysqli-functions, it fails at the very beginning with the above error message. The scripts itself all come from a different system with same PHP-version where they worked properly. The weird thing is: this happens only when calling a script from CLI, when running the same from Apache2, everything is fine. What I have done:

  • Symlink from /etc/php/7.2/cli to /etc/php/7.2/apache2 so that both are guaranteed to use the same configuration
  • MySQL-package installed (elsewhere it would not work in Apache)
  • MySQL-package enabled (elsewhere it would not work in Apache)

Any ideas what still could be wrong here?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Elmi
  • 5,899
  • 15
  • 72
  • 143
  • 1
    Run `php -i` and see which configuration files are in use. Then edit the appropriate file to enable the mysqli extension – Phil Oct 21 '20 at 05:26
  • Have you tried this? https://stackoverflow.com/questions/49292104/php-warning-php-startup-unable-to-load-dynamic-library-usr-lib-php-20151012 – Dharman Oct 21 '20 at 11:17
  • @Phil both, root and the standard user are using the same ini files – Elmi Oct 21 '20 at 17:33
  • 1
    Show us the part of the INI file where you load the extensions. – Dharman Oct 21 '20 at 17:35
  • Dharman: it is in /etc/php/7.2/cli/conf.d/20-mysqli.ini and contains "extension=mysqli.so" (default Ubuntu 18.04 settings) – Elmi Oct 22 '20 at 11:24

0 Answers0