'PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll
I have ubuntu 14.04 EC2 instance. I have installed php 7 on it. when I execute any php command like php --version or any other. I get following error
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_mysqli.dll' - /usr/lib/php/20151012/php_mysqli.dll: cannot open shared object file: No such file or directory in Unknown on line 0
I have tried following
- enable php_mysqli.dll in php.ini
- enable mysqli.so
- enable php_mysqli.so
- sudo apt-get install php-mysql
but nothing worked for me.
Any suggestion how I can solve this?
Solution 1:[1]
If you are on Linux, you shouldn't have DLL files but SO files. So first, you have to remove / disable the php_mysqli.dll you added in php.ini.
In order to use mysqli, you should then :
- install the package for Ubuntu :
apt-get install php-mysql
- check if it is already enabled (with
phpinfo()
for example) - if not enabled, enable the module - check in
/etc/php/mods-available/
folder if there is amysqli.ini
, containingextension=mysqli.so
, then check for CLI / FPM / Apache / other if there is the symbolic link pointing to this file (for example for CLI, in/etc/php/cli/conf.d/
:20-mysqli.ini -> ../../mods-available/mysqli.ini
) - restart php / apache / nginx depending what you are using
Solution 2:[2]
In my case, it happened because I uncommented the extension=php_mysqli.dll
line in php.ini file for running some other package. After Googling around I found that you should not uncomment anything directly from php.ini instead you should install the required PHP extension and it will do the rest.
Solution 3:[3]
I have recently encountered this problem on ubuntu16.04, I finally resolve it by adding a semi-colon at each line like extension=php_*.dll
,I think that is because LAMP on ubuntu is intelligent enough?it automatically opens all of the extensions for us. And on windows,we have to enable the extensions manually by remove the semi-colon at each line like ;extension=php_*.dll
in php.ini
.
Solution 4:[4]
Run Phpinfo()
Search for your php.ini
path
search extension=php_mysqli.so
comment like this
;extension=php_mysqli.so
Solution 5:[5]
I just had the same problem and realised they were two folders in my /etc/php/7.0
, which were apache2
and cli
. Turned out the extension line in cli/php.ini
was uncommented with the dll file, not the one in apache2
directory. Commenting it just solved the problem.
Solution 6:[6]
I managed to solved it like this:
add libs to php.ini (etc/php/7.3/apache2; etc/php/7.3/cli folders) extension=pdo_mysql.so
restart apache (sudo systemctl restart apache2)
comment libs in php.ini (etc/php/7.3/apache2; etc/php/7.3/cli folder) extension=pdo_mysql.so
go etc/php/7.3/mod_available
comment extension (because it is already loaded), for example, etc/php/7.3/mod_available/pdo_mysql.ini ;extension=pdo_mysql.so
Solution 7:[7]
If you are on Linux and using php8.1,
- try to commenting extension=pdo_mysql in directory /etc/php/8.1/cli/php.ini file if the extension is uncommenting
- uncommenting extension=pdo_mysql in directory /etc/php/8.1/apache2/php.ini file if the extension is commenting
this method work for me
Solution 8:[8]
If you see mcrypt.so under /etc/php/7.2 or /etc/php/7.3 just delete it and restart the server it will resolve the issue. As when we updrage the php to latest version that file may get stored to latest versions which is not required.
I used following commands:
cd /etc/php/7.3
sudo rm -rf mcrypt.so
sudo service apache2 restart
Solution 9:[9]
Just comment out all lines with .dll extensions because you are on Ubuntu. Ubuntu support .so files.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow