PHP 警告:PHP 启动:无法加载动态库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5282264/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 20:51:17  来源:igfitidea点击:

PHP Warning: PHP Startup: Unable to load dynamic library

phpdynamic-library

提问by Popolo

I run a PHP script and get this error:

我运行一个 PHP 脚本并收到此错误:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/ixed.5.2.lin' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/ixed.5.2.lin: cannot open shared object file: No such file or directory in Unknown on line 0

PHP 警告:PHP 启动:无法加载动态库 '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/ixed.5.2.lin' - /usr/local/lib/php/extensions /no-debug-non-zts-20090626/ixed.5.2.lin: 无法打开共享对象文件:第 0 行的 Unknown 中没有这样的文件或目录

What does that mean?

这意味着什么?

回答by Pascal MARTIN

It means there is an extension=...or zend_extension=...line in one of your php configuration files (php.ini, or another close to it)that is trying to load that extension : ixed.5.2.lin

这意味着在您的一个 php 配置文件(php.ini 或另一个接近它的文件)中有一行extension=...zend_extension=...一行试图加载该扩展:ixed.5.2.lin

Unfortunately that file or path doesn't exist or the permissions are incorrect.

不幸的是,该文件或路径不存在或权限不正确。

  1. Try to search in the .inifiles that are loaded by PHP (phpinfo()can indicate which ones are) - one of them should try to load that extension.
  2. Either correct the path to the file or comment out the corresponding line.
  1. 尝试在.iniPHP 加载的文件中进行搜索(phpinfo()可以指出哪些是)——其中之一应该尝试加载该扩展。
  2. 更正文件路径或注释掉相应的行。

回答by nefski

If you're on Linux, you can find all loaded configuration files by typing this in shell:

如果您使用的是 Linux,则可以通过在 shell 中键入以下内容来找到所有已加载的配置文件:

php -r "print phpinfo();" | grep ".ini"

UPDATE: As mentioned in comments, this can be even more accurate:

更新:正如评论中提到的,这可能更准确:

php -i | grep ini

回答by EternalHour

If you just want to make the error disappear, and you don't need the extension, then by all means comment the line out in php.ini. But if you actually want to fix the problem here is some additional info.

如果你只是想让错误消失,而你不需要扩展名,那么一定要在php.ini. 但是如果你真的想解决这个问题,这里有一些额外的信息。

There are various causes for this based on the exact module, but there are also some general guidelines.

基于确切的模块,造成这种情况的原因有多种,但也有一些一般准则。

  1. Open phpinfo()and look for extension_dirunder the Coresection. This is where your modules should be located.
  1. 打开phpinfo()extension_dir在该Core部分下查找。这是您的模块应位于的位置。

For instance, /usr/lib/php/modulesfor Unix/Linux.

例如,/usr/lib/php/modules对于 Unix/Linux。

  1. If the file does in fact exist, make sure permissions are adequate.
  2. If the file does not exist, use the resources below to install it.
  1. 如果该文件确实存在,请确保权限足够。
  2. 如果该文件不存在,请使用以下资源进行安装。

Installation on *nix (PEAR)
Installation of extensions on Windows

在 *nix (PEAR) 上
安装 在 Windows 上安装扩展

回答by Technotronic

phpStom with XAMPP

带有 XAMPP 的 phpStom

TL;DR Except from verifying that the files exist, you might need to add the drive letter to some records in your php.ini file

TL;DR 除了验证文件是否存在之外,您可能需要将驱动器号添加到 php.ini 文件中的某些记录中

I suddenly started having a problem using phpStorm 7 for debugging php with xampp and xdebug. When trying to set intellij interperter to be xampps php I got a lot of the warnings like the one in the question, for example:

我突然开始在使用 phpStorm 7 使用 xampp 和 xdebug 调试 php 时遇到问题。当尝试将 intellij interperter 设置为 xampps php 时,我收到了很多警告,例如问题中的警告,例如:

Unable to load dynamic library '/xampp/php/ext/php_bz2.dll'

无法加载动态库 '/xampp/php/ext/php_bz2.dll'

For some reason I had to add my drive letter to the records of extension_dir and browscap in the php.ini file:

出于某种原因,我不得不将我的驱动器号添加到 php.ini 文件中 extension_dir 和 browscap 的记录中:

extension_dir = "\xampp\php\ext"
browscap = "\xampp\php\extras\browscap.ini"

to

extension_dir = "e:\xampp\php\ext"
browscap = "e:\xampp\php\extras\browscap.ini"

回答by B?a?ej Krzakala

php -r "echo php_ini_loaded_file();"

php -r "echo php_ini_loaded_file();"

Will show in CLI current ini loaded file, search there for Your extension, path to it is incorrect.

将在 CLI 当前加载的 ini 文件中显示,在那里搜索您的扩展名,它的路径不正确。

回答by Marco D.G.

Loading .dll in Linux

在 Linux 中加载 .dll

I've encountered this warning message while I was trying to install a php-extensionvia the php.inifile;

我在尝试通过php.ini文件安装php-extension时遇到了此警告消息;

until I figured out that you cannot load .dllextensions in Linux,

直到我发现你不能在 Linux 中加载.dll扩展名,

but you have to commentthe extensions that you want to import ;extension= ... .dlland install it correctlyvia sudo apt-get install php-...

但是您必须注释要导入的扩展;extension= ... .dll并通过以下方式正确安装它sudo apt-get install php-...

note: ...is the extension name you want to enable.

注意...是您要启用的扩展名。

回答by Volomike

Note that you can also get this error if your PHP library doesn't have the "other" directory opening permission. In my particular case, I noticed this when using php -lto syntax check a script in my text editor. This meant that since my account was called "volomike", that account didn't have permission to run the libraries that the phpcommand relied upon.

请注意,如果您的 PHP 库没有“其他”目录打开权限,您也会收到此错误。在我的特殊情况下,我在使用php -l文本编辑器中的语法检查脚本时注意到了这一点。这意味着由于我的帐户名为“volomike”,该帐户无权运行该php命令所依赖的库。

For instance, on Ubuntu 14.04, I had PHP5 installed automatically into the path /usr/lib/php5/20121212+lfs. However, because I was working in C++ in building some shared objects, I messed around with the directory permissions and screwed things up such that non-root accounts did not have the directory execute (directory open) permissions to view /usr/lib/php5/20121212+lfs. So, I typed the following command to rectify that problem:

例如,在 Ubuntu 14.04 上,我将 PHP5 自动安装到路径中/usr/lib/php5/20121212+lfs。但是,因为我使用 C++ 构建一些共享对象,所以我弄乱了目录权限并将事情搞砸了,以至于非 root 帐户没有目录执行(打开目录)权限来查看/usr/lib/php5/20121212+lfs. 所以,我输入了以下命令来纠正这个问题:

sudo chmod o+x /usr/lib/php5/20121212+lfs.

sudo chmod o+x /usr/lib/php5/20121212+lfs.

Now when I do php -l example.phpas a non-root user, it never gives me this "Unabled to load dynamic library" problem anymore.

现在,当我php -l example.php以非 root 用户身份进行操作时,它再也不会出现“无法加载动态库”的问题。

回答by Prima Putra

I had the same problem on XAMPP for Windows when I try to install composer. I did php -vand php throwing error :

当我尝试安装 Composer 时,我在 XAMPP for Windows 上遇到了同样的问题。我做了php -v和 php 抛出错误:

Unable to load dynamic library '/xampp/php/ext/php_bz2.dll'

无法加载动态库 '/xampp/php/ext/php_bz2.dll'

It took me a while until I realized that I need to setup my XAMPP. So I run setup_xampp.batand php return to works like a charm.

我花了一段时间才意识到我需要设置我的 XAMPP。所以我运行setup_xampp.bat并且 php 返回工作就像一个魅力。

回答by Anjani Barnwal

I had the same problem on XAMPP for Windows10 when I try to install composer.

当我尝试安装 Composer 时,我在 Windows10 的 XAMPP 上遇到了同样的问题。

Unable to load dynamic library '/xampp/php/ext/php_bz2.dll'

无法加载动态库 '/xampp/php/ext/php_bz2.dll'

Then follow this steps

然后按照这个步骤

  1. just open your current_xampp_containing_drive:\xampp(default_xampp_folder)\php\php.ini in texteditor (like notepad++)
  2. now just find - is the current_xampp_containing_drive:\xampp exist?
  3. if not then find the "extension_dir" and get the drive name(c,d or your desired drive) like.
  1. 只需在文本编辑器(如记事本++)中打开您的 current_xampp_ contains_drive:\xampp(default_xampp_folder)\php\php.ini
  2. 现在只需找到 - current_xampp_ contains_drive:\xampp 是否存在?
  3. 如果没有,则找到“extension_dir”并获取驱动器名称(c、d 或您想要的驱动器)。

extension_dir="F:\xampp731\php\ext" (here finded_drive_name_from_the_file is F)

extension_dir="F:\xampp731\php\ext"(这里finded_drive_name_from_the_file 是F)

  1. again replace with finded_drive_name_from_the_file:\xampp with current_xampp_containing_drive:\xampp and save.
  2. now again start the composer installation progress, i think your problem will be solved.
  1. 再次用 found_drive_name_from_the_file:\xampp 替换为 current_xampp_ contains_drive:\xampp 并保存。
  2. 现在再次开始composer安装进度,我想你的问题会解决的。

回答by Mehmet F Erten

After Windows 10 XAMPPnow I installed LAMPP (XAMPP)on Ubuntu. Windows XAMPPhad a lot less to configure compare to MAC (iOS) but now with Linux Ubuntu I had a few more since there are more going in Linux (a good thing).

之后Windows 10 XAMPP,现在我安装LAMPP (XAMPP)在Ubuntu。Windows XAMPP与 MAC (iOS) 相比,要配置的要少得多,但现在使用 Linux Ubuntu 我有更多的配置,因为 Linux 中的配置更多(一件好事)。

I confused and activated mysqli.dll(and mysql.dll: erase "#" in /etc/php/7.2/cli/php.ini

我混淆并激活mysqli.dll(和mysql.dll:擦除“#”中的/etc/php/7.2/cli/php.ini

I started to get the PHP Warning: PHP Startup: Unable to load dynamic librarymessage related to dll. I commented out mysql(and i).dllin the same file but the message didn't go away up until I commented out " " in /opt/lampp/etc/php.ini.

我开始收到PHP Warning: PHP Startup: Unable to load dynamic librarydll. 我mysql(and i).dll在同一个文件中注释掉了,但是直到我在/opt/lampp/etc/php.ini.

Looks like XAMPP reads php.inifile from /etc/php/7.2/cliand makes modification in php.iniof /opt/lampp/etc. (;extension=php_pdo_mysql.dll after ";" restarted Apache and no more any message.

像XAMPP长相读取php.ini从文件/etc/php/7.2/cli,并使得修改php.ini/opt/lampp/etc。(;extension=php_pdo_mysql.dll 在 ";" 重新启动 Apache 后没有任何消息。