Error In PHP5 ..Unable to load dynamic library


71
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

Answers:


141

Even though several other answers suggest it, installing more unnecessary software is generally not the 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:

First, find out which files are trying to load the above extensions:

$ grep -Hrv ";" /etc/php5 | grep -E "extension(\s+)?="

Example output for 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.


4
I encountered the same errors after a dist-upgrade from Debian 6.x to 7.1. I didn't know suhosin and idn modules got removed in this newer packages.. so big thx for the nice grep line.
Daniel W.

Thank you very much. This worked pretty fine in Ubuntu 12.04.2 LTS. I yet have a question: If I disable the extensions causing the error by placing a ; symbol at the beggining of the line, will they be re-enabled after an upgrade?
Geppettvs D'Constanzo

1
@GeppettvsD'Constanzo When upgrading, sometimes it will prompt you whether to overwrite the config file. If you overwrite it, it MAY overwrite these ones, but I'm not too sure. Just choose no.
Mike

1
I agree, if you don't need it the extension why install it?
d0001

1
I like this kind of answers because they make you understand what's going on AKA = know-how
nulll

47
sudo apt-get install php5-mcrypt
sudo apt-get install php5-mysql

...etc resolved it for me :)

hope it helps


Your answer got my site working again! thank you so much, I really appreciate this. I have spend hours on this. I followed some instructions to upgrade mysql and they must have omitted this part.
pgee70

13

Look /etc/php5/cli/conf.d/ and delete corresponding *.ini files. This error happens when you remove some php packages not so cleanly.


12

Seems like you upgraded PHP to newer version and old .ini files are still pointing to old location.

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

The .ini files giving you an error are located at /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:

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:

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.


6

如果你把; 符号,此操作使扩展无效。

我遇到了同样的问题,并执行了以下操作:

  1. 使用清除参数卸载php:

    sudo apt-get --purge remove php5-common
    
  2. 并再次安装:

    sudo apt-get install php5 php5-mysql
    

2

我的问题通过以下命令解决了

sudo apt-get install php5-mcrypt

我有

  • 具有Suhosin-Patch的PHP 5.3.10-1ubuntu3.4(CLI)
  • Ubuntu桌面12.04
  • 的MySQL 5.5

2

我通过blog.tordeu.com找到了这个解决方案,

sudo aptitude purge php5-suhosin

我不确定,但是似乎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

2

如果您使用的是5.6 php,

须藤apt-get install php5.6-curl


我用命令安装了7. * php:sudo apt-get install php-curl
Ravistm


0

对于Ubuntu 14.04,我只为mcrypt遇到了这个错误:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/mcrypt.ini' - /usr/lib/php5/20121212/mcrypt.ini: cannot open shared object file: No such file or directory in Unknown on line 0

如果您仔细检查该错误,则php在该位置正在寻找mcrypt.ini而不是mcrypt.so。我只是将mcrypt.so复制到mcrypt.ini,仅此而已,警告消失了,并且该扩展名现在已正确安装。它可能看起来有点脏,但是可以用!


0

我已经通过取消注释在php.ini中启用了extension_dir,

  extension_dir = "ext"
  extension=phpchartdir550.dll

并将phpchartdir550 dll复制到extension_dir(/ usr / lib / php5 / 20121212),导致相同的错误。

  PHP Warning:  PHP Startup: Unable to load dynamic library 'ext/phpchartdir550.dll' - ext/phpchartdir550.dll: cannot open shared object file: No such file or directory in Unknown on line 0
  PHP Warning:  PHP Startup: Unable to load dynamic library 'ext/pdo.so' - ext/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 'ext/gd.so' - ext/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0

正如@Mike所指出的,当应用程序中实际上不需要它们时,不必安装所有东西。

比较简单的方法是将库复制到正确的位置后,提供要加载的扩展的完整路径。

将phpchartdir550.dll复制到/ usr / lib / php5 / 20121212,这是我的Ubuntu 14.04中的extension_dir(可以使用phpinfo()看到),然后在php.ini中提供该库的完整路径,

;   extension=/path/to/extension/msql.so
extension=/usr/lib/php5/20121212/phpchartdir550.dll

重新启动apache:sudo服务apache2重新启动

即使其他.so出现在同一目录中,也只能选择加载所需的.so。


0

我有一个类似的问题,这导致我来到这里:

$ 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.

与上述不同,安装软件无法解决我的问题,因为我已经安装了它。

$ 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.

我通过以下方式找到了解决方案:Debian错误报告日志

$ sudo vim /etc/php5/mods-available/uprofiler.ini

我编辑了ini文件,愉快地将extension = profiler.so更改为extension = uprofiler.so ....结果:

$ phpunit --version
PHPUnit 5.7.17 by Sebastian Bergmann and contributors.

即不再警告。


0

(对于Ubuntu用户)

我遇到了同样的问题,但以上答案均未解决。这是我解决问题的方法。

打开php.ini文件(我的文件在/etc/php/7.3/cli/php.ini)。

您可能会遇到以下情况:

extension=pdo_mysql

或许:

extension=/here/is/the/path/to/your/file/pdo_mysql.so

在下面添加以下行 extension=pdo_mysql

extension=pdo

因此,您将拥有:

extension=pdo
extension=pdo_mysql

似乎问题是(至少在我看来),我们需要先加载pdo扩展程序才能加载pdo_mysql扩展程序。

希望有帮助!

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.