[英]PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll
I have ubuntu 14.04 EC2 instance.我有 ubuntu 14.04 EC2 实例。 I have installed php 7 on it.我已经在上面安装了 php 7。 when I execute any php command like php --version or any other.当我执行任何 php 命令时,如 php --version 或任何其他命令。 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我试过以下
but nothing worked for me.但对我没有任何用处。
Any suggestion how I can solve this?有什么建议我可以解决这个问题吗?
If you are on Linux, you shouldn't have DLL files but SO files.如果你在 Linux 上,你不应该有 DLL 文件,而是 SO 文件。 So first, you have to remove / disable the php_mysqli.dll you added in php.ini.因此,首先,您必须删除/禁用您在 php.ini 中添加的 php_mysqli.dll。
In order to use mysqli, you should then :为了使用 mysqli,你应该:
apt-get install php-mysql
为 Ubuntu 安装软件包: apt-get install php-mysql
phpinfo()
for example)检查它是否已经启用(例如使用phpinfo()
)/etc/php/mods-available/
folder if there is a mysqli.ini
, containing extension=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
)如果未启用,请启用模块 - 检查/etc/php/mods-available/
文件夹,如果有mysqli.ini
,包含extension=mysqli.so
,然后检查 CLI / FPM / Apache / other 如果有符号指向此文件的链接(例如,对于 CLI,在/etc/php/cli/conf.d/
: 20-mysqli.ini -> ../../mods-available/mysqli.ini
)In my case it happened because i uncommented the extension=php_mysqli.dll
line in php.ini file for running some other package.就我而言,这是因为我取消了 php.ini 文件中的extension=php_mysqli.dll
行的注释,以运行其他一些包。 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.在谷歌搜索之后,我发现你不应该直接从 php.ini 取消注释任何东西,而是应该安装所需的 php 扩展,剩下的就交给它了。
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.最近在ubuntu16.04上遇到这个问题,最后在每一行加一个分号解决了,比如extension=php_*.dll
,我想是因为ubuntu上的LAMP足够智能,它会自动打开所有的我们的扩展。 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
.在 Windows 上,我们必须通过删除每一行的分号来手动启用扩展,例如;extension=php_*.dll
in php.ini
。
Run Phpinfo()
Search for your php.ini
path运行Phpinfo()
搜索你的php.ini
路径
search extension=php_mysqli.so
搜索extension=php_mysqli.so
comment like this像这样评论
;extension=php_mysqli.so
If you are on Linux and using php8.1,如果您使用 Linux 并使用 php8.1,
this method work for me这种方法对我有用
I just had the same problem and realised they were two folders in my /etc/php/7.0
, which were apache2
and cli
.我刚刚遇到了同样的问题,并意识到它们是我的/etc/php/7.0
中的两个文件夹,分别是apache2
和cli
。 Turned out the extension line in cli/php.ini
was uncommented with the dll file, not the one in apache2
directory.原来cli/php.ini
的扩展行没有用 dll 文件注释,而不是apache2
目录中的那个。 Commenting it just solved the problem.评论它只是解决了问题。
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将库添加到 php.ini (etc/php/7.3/apache2; etc/php/7.3/cli 文件夹) extension=pdo_mysql.so
restart apache (sudo systemctl restart apache2)重启 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 php.ini 中的注释库(etc/php/7.3/apache2; etc/php/7.3/cli 文件夹) extension=pdo_mysql.so
go etc/php/7.3/mod_available去 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注释扩展(因为已经加载了),例如 etc/php/7.3/mod_available/pdo_mysql.ini ;extension=pdo_mysql.so
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.如果您在 /etc/php/7.2 或 /etc/php/7.3 下看到 mcrypt.so 只需将其删除并重新启动服务器即可解决问题。 As when we updrage the php to latest version that file may get stored to latest versions which is not required.当我们将 php 升级到最新版本时,该文件可能会存储到不需要的最新版本。
I used following commands:我使用了以下命令:
cd /etc/php/7.3 cd /etc/php/7.3
sudo rm -rf mcrypt.so须藤 rm -rf mcrypt.so
sudo service apache2 restart须藤服务 apache2 重启
Just comment out all lines with .dll extensions because you are on Ubuntu.只需注释掉所有带有 .dll 扩展名的行,因为您使用的是 Ubuntu。 Ubuntu support .so files. Ubuntu 支持 .so 文件。
In php.ini
under Dynamic Extensions
the line extension=php_mysqli.dll
was enabled.在Dynamic Extensions
下的php.ini
行extension=php_mysqli.dll
已启用。
I disabled it by adding a semi-colon at the head of the line ;extension=php_mysqli.dll
.我通过在行的开头添加一个分号来禁用它;extension=php_mysqli.dll
。
Saved and exited php.ini
.保存并退出php.ini
。 Restarted Apache
.重新启动Apache
。
This resolved the error for me.这为我解决了错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.