php PHP5中的错误..无法加载动态库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10565521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error In PHP5 ..Unable to load dynamic library
提问by user1391283
root@ip-10-131-9-200:/etc/php5/apache2# php -a
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/curl.so' - /usr/lib/php5/20090626+lfs/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mcrypt.so' - /usr/lib/php5/20090626+lfs/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo.so' - /usr/lib/php5/20090626+lfs/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
Interactive shell
回答by Mike
Even though several other answers suggest it, installing more unnecessary software is generally notthe best solution. Instead, you should fix the underlying problem. The reason these messages appear is because you are trying to load those extensions, but they are not installed. So the easy solution is simply to tell PHP to stop trying to load them:
尽管其他几个答案表明了这一点,但安装更多不必要的软件通常不是最佳解决方案。相反,您应该解决根本问题。出现这些消息的原因是您正在尝试加载这些扩展,但未安装它们。所以简单的解决方案就是告诉 PHP 停止尝试加载它们:
First, find out which files are trying to load the above extensions:
首先,找出哪些文件正在尝试加载上述扩展名:
$ grep -Hrv ";" /etc/php5 | grep -E "extension(\s+)?="
Example output for Ubuntu:
Ubuntu 的示例输出:
/etc/php5/mods-available/gd.ini:extension=gd.so
/etc/php5/mods-available/pdo_sqlite.ini:extension=pdo_sqlite.so
/etc/php5/mods-available/pdo.ini:extension=pdo.so
/etc/php5/mods-available/pdo_mysql.ini:extension=pdo_mysql.so
/etc/php5/mods-available/mysqli.ini:extension=mysqli.so
/etc/php5/mods-available/mysql.ini:extension=mysql.so
/etc/php5/mods-available/curl.ini:extension=curl.so
/etc/php5/mods-available/sqlite3.ini:extension=sqlite3.so
/etc/php5/conf.d/mcrypt.ini:extension=mcrypt.so
/etc/php5/conf.d/imagick.ini:extension=imagick.so
/etc/php5/apache2/php.ini:extension=http.so
Now just find the files that are loading the extensions that are causing the errors and comment out those lines with a ;. For some reason this happened to me with the default install of Ubuntu, so hopefully this helps someone else.
现在只需找到正在加载导致错误的扩展名的文件,并用;. 出于某种原因,这发生在我的默认安装 Ubuntu 上,所以希望这对其他人有所帮助。
回答by user1568807
sudo apt-get install php5-mcrypt
sudo apt-get install php5-mysql
...etc resolved it for me :)
...等为我解决了它:)
hope it helps
希望能帮助到你
回答by dimcha
Look /etc/php5/cli/conf.d/ and delete corresponding *.ini files. This error happens when you remove some php packages not so cleanly.
查看 /etc/php5/cli/conf.d/ 并删除相应的 *.ini 文件。当您不那么干净地删除一些 php 包时,会发生此错误。
回答by ruuter
Seems like you upgraded PHPto newer version and old .ini files are still pointing to old location.
似乎您已将 PHP 升级到较新版本,而旧的 .ini 文件仍指向旧位置。
The solution: find out where are modules located now
解决方案:找出模块现在位于何处
ls -l /usr/lib/php5
There should be a directory similar to old 20090626. In my case it is now 20131226
应该有一个类似于 old 的目录20090626。就我而言,现在是20131226
The .ini files giving you an error are located at /etc/php5/cli/conf.d/
给你一个错误的 .ini 文件位于 /etc/php5/cli/conf.d/
Just edit those .ini files which module gives you an error. For example, in case the error is for mcrypt module:
只需编辑那些模块给您错误的 .ini 文件。例如,如果错误是针对 mcrypt 模块的:
sudo vi /etc/php5/cli/conf.d/20-mcrypt.ini
Change the line:
更改行:
extension=/usr/lib/php5/20090626/mcrypt.so
to reflect the new path for .so file. In my case the correct path should be:
以反映 .so 文件的新路径。在我的情况下,正确的路径应该是:
extension=/usr/lib/php5/20131226/mcrypt.so
That's it! The error is gone. Ofc you'd have to do it with each module giving you an error.
就是这样!错误消失了。Ofc 你必须对每个给你一个错误的模块做这件事。
回答by José Ayrám
If you put the ; symbol, this action inactive the extension.
如果你把; 符号,此操作使扩展无效。
I had the same problem and did the following:
我遇到了同样的问题并执行了以下操作:
Uninstall php with purge parameter:
sudo apt-get --purge remove php5-commonAnd install again:
sudo apt-get install php5 php5-mysql
使用清除参数卸载 php:
sudo apt-get --purge remove php5-common并再次安装:
sudo apt-get install php5 php5-mysql
回答by Edwin Yip
I found this solution by blog.tordeu.com, and it's
我通过blog.tordeu.com找到了这个解决方案,它是
sudo aptitude purge php5-suhosin
I'm not sure, but it seems that the suhosinis no longer needed, it worked for my, my PHP version:
我不确定,但似乎suhosin不再需要它,它适用于我的 PHP 版本:
PHP 5.4.34-1+deb.sury.org~lucid+1 (cli) (built: Oct 17 2014 15:26:51)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
回答by GP Das
My problem was solved by the following command
我的问题是通过以下命令解决的
sudo apt-get install php5-mcrypt
I have
我有
- PHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli)
- Ubuntu Desktop 12.04
- Mysql 5.5
- PHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli)
- Ubuntu 桌面 12.04
- mysql 5.5
回答by Amjith
If you are using 5.6 php,
如果您使用的是 5.6 php,
sudo apt-get install php5.6-curl
须藤 apt-get 安装 php5.6-curl
回答by owenmck
I had a similar problem, which led me here:
我有一个类似的问题,这导致我来到这里:
$ phpunit --version
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20131226/profiler.so' - /usr/lib/php5/20131226/profiler.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHPUnit 5.7.17 by Sebastian Bergmann and contributors.
Unlike the above, installing the software did not resolve my problem because I already had it.
与上述不同,安装该软件并没有解决我的问题,因为我已经有了它。
$ sudo apt-get install php5-uprofiler
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5-uprofiler is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 52 not upgraded.
I found my solution via : Debian Bug report logs
我通过以下方式找到了解决方案:Debian Bug 报告日志
$ sudo vim /etc/php5/mods-available/uprofiler.ini
I edited the ini file, changing extension=profiler.soto extension=uprofiler.so.... the result, happily:
我编辑了 ini 文件,将extension=profiler.so更改为extension=uprofiler.so.... 结果,很高兴:
$ phpunit --version
PHPUnit 5.7.17 by Sebastian Bergmann and contributors.
i.e. no more warning.
即没有更多的警告。
回答by Student of Science
(For Ubuntu users)
(对于 Ubuntu 用户)
I had the same problem, but none of the answers above solved that. Here is how I solved the problem.
我有同样的问题,但上面的答案都没有解决这个问题。这是我解决问题的方法。
Open your php.inifile (mine was in /etc/php/7.3/cli/php.ini).
打开你的php.ini文件(我的在/etc/php/7.3/cli/php.ini)。
You may have something like this:
你可能有这样的事情:
extension=pdo_mysql
Or maybe:
或者可能:
extension=/here/is/the/path/to/your/file/pdo_mysql.so
Add the following line before extension=pdo_mysql
在前面添加以下行 extension=pdo_mysql
extension=pdo
So, you will have:
因此,您将拥有:
extension=pdo
extension=pdo_mysql
It seems that the problem is (at least in my case) that we need to load pdoextension first to load the pdo_mysqlextension.
似乎问题是(至少在我的情况下)我们需要先加载pdo扩展才能加载pdo_mysql扩展。
Hope that helps!
希望有帮助!

