PHP 警告:PHP 启动:无法加载动态库
我运行 PHP 脚本并收到此错误:
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 行的未知中没有这样的文件或目录
这是什么意思?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(20)
这意味着您的 php 配置文件之一中有一个
extension=...
或zend_extension=...
行(php.ini,或另一个接近它)正在尝试加载该扩展:ixed.5.2.lin
不幸的是,该文件或路径不存在或权限不正确。
.ini
文件中进行搜索(phpinfo()
可以指示是哪些文件) - 其中一个应该尝试加载该扩展。It means there is an
extension=...
orzend_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
Unfortunately that file or path doesn't exist or the permissions are incorrect.
.ini
files that are loaded by PHP (phpinfo()
can indicate which ones are) - one of them should try to load that extension.如果您使用的是 Linux,则可以通过在 shell 中键入以下内容来找到所有加载的配置文件:
更新:
正如评论中提到的,这可能更准确:
If you're on Linux, you can find all loaded configuration files by typing this in shell:
UPDATE:
As mentioned in comments, this can be even more accurate:
phpStom 与 XAMPP
TL;DR 除了验证文件是否存在之外,您可能需要将驱动器号添加到 php.ini 文件中的某些记录
我突然开始有一个使用 phpStorm 7 通过 xampp 和 xdebug 调试 php 时出现问题。当尝试将 intellij interperter 设置为 xampps php 时,我收到了很多警告,例如问题中的警告,例如:
器号添加到 php.ini 文件中的 extension_dir 和 browscap 的记录中:
由于某种原因,我必须将驱动
phpStom with XAMPP
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
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:
For some reason I had to add my drive letter to the records of extension_dir and browscap in the php.ini file:
to
如果您只是想让错误消失,并且不需要扩展,那么请务必在
php.ini
中注释掉该行。但如果您确实想解决问题,这里有一些附加信息。根据具体模块,造成这种情况的原因有多种,但也有一些通用准则。
phpinfo()
并在Core
部分下查找extension_dir
。这是您的模块应该位于的位置。在 *nix (PEAR) 上安装
在 Windows 上安装扩展
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.There are various causes for this based on the exact module, but there are also some general guidelines.
phpinfo()
and look forextension_dir
under theCore
section. This is where your modules should be located.Installation on *nix (PEAR)
Installation of extensions on Windows
在 Linux 中加载 .dll
我在尝试通过 php.ini 安装 php-extension 时遇到了此警告消息> 文件;
直到我发现你无法在Linux中加载.dll扩展,
但你必须注释你想要导入的扩展
;extension= ... .dll
并通过sudo apt-get install php-...正确安装
注意:
...
是您要启用的扩展名。Loading .dll in Linux
I've encountered this warning message while I was trying to install a php-extension via the php.ini file;
until I figured out that you cannot load .dll extensions in Linux,
but you have to comment the extensions that you want to import
;extension= ... .dll
and install it correctly viasudo apt-get install php-...
note:
...
is the extension name you want to enable.php -r "echo php_ini_loaded_file();"
将在 CLI 中显示当前 ini 加载的文件,在那里搜索您的扩展名,其路径不正确。
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.
就我而言,当我将 php 版本更新到 7.4 时,此消息开始出现。
为了解决这个问题,我必须查找 php 版本文件夹(/etc/php/7.4/apache2/ && /etc/php/7.4/cli/)中找到的 php.ini 文件,检查扩展名所在的行可以看到扩展 gd2 和 intl 未被注释。
In my case, this message started to appear when I updated the php version to 7.4.
To solve it I had to look for the php.ini files found inside the php version folder (/etc/php/7.4/apache2/ && /etc/php/7.4/cli/) checking the lines where the extensions I could see that the extensions gd2 and intl were uncommented.
当我在服务器上并行运行不同版本的 PHP 时,许多模块都出现此错误。为了解决这个问题,我需要安装它无法找到的特定 PHP 版本的软件包。因此,例如,如果我看到:-
我会专门安装 PHP 版本的库:-
然后重新启动 Apache。为我修好了。您可以这样检查您的版本:-
I had this error on a number of modules when I had been running different versions of PHP side by side on my server. To sort this out, I needed to install the packages it couldn't find for that specific PHP version. So, for example, if I saw:-
I would install the library for the PHP version specifically:-
And then restart Apache. Fixed it for me. You can check your version like this:-
请注意,如果您的 PHP 库没有“其他”目录打开权限,您也可能会收到此错误。在我的特定情况下,我在使用 php -l 在文本编辑器中对脚本进行语法检查时注意到了这一点。这意味着,由于我的帐户名为“volomike”,因此该帐户无权运行
php
命令所依赖的库。例如,在 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
。现在,当我以非 root 用户身份执行 php -l example.php 时,它再也不会出现“无法加载动态库”问题了。
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 -l
to 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 thephp
command relied upon.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:sudo chmod o+x /usr/lib/php5/20121212+lfs
.Now when I do
php -l example.php
as a non-root user, it never gives me this "Unabled to load dynamic library" problem anymore.当我尝试安装 Composer 时,我在 Windows 版 XAMPP 上遇到了同样的问题。
我做了
php -v
和 php 抛出错误:我花了一段时间才意识到我需要设置我的 XAMPP。所以我运行
setup_xampp.bat
并且 php 恢复正常工作。I had the same problem on XAMPP for Windows when I try to install composer.
I did
php -v
and php throwing error :It took me a while until I realized that I need to setup my XAMPP. So I run
setup_xampp.bat
and php return to works like a charm.当我尝试安装 Composer 时,我在 Windows10 的 XAMPP 上遇到了同样的问题。
然后按照以下步骤操作,
I had the same problem on XAMPP for Windows10 when I try to install composer.
Then follow this steps
我所做的是;
1 - 我首先通过 phpinfo() 函数了解我使用的 PHP 版本
2 - 从那里您将找到配置(php.ini)文件的位置
3 - 打开文件
4 - 注释掉类似于下图的行
What I did was;
1 - I first find out what version of PHP I am using thru the function phpinfo()
2 - From there you will find the location of your configuration(php.ini) file
3 - Open that file
4 - Comment out the line similar to the image below
就我而言,我收到此错误是因为我下载了 dll 的线程安全版本(固定为
-ts-
),但我安装的 php 是非线程安全版本(固定为>-nts-
)。下载正确版本的 dll(与我的 php 安装版本完全匹配)解决了该问题。In my case I got this error because I downloaded a thread-safe version of the dll (infixed with
-ts-
), but my installation of php was a non-thread-safe (infixed with-nts-
). Downloading the right version of the dll, exactly matching my php installation version fixed the issue.在安装了
Windows 10 XAMPP
之后,我现在在 Ubuntu 上安装了LAMPP (XAMPP)
。与 MAC (iOS) 相比,Windows XAMPP 的配置要少得多,但现在使用 Linux Ubuntu,我的配置要多一些,因为 Linux 中的配置更多(这是一件好事)。我困惑并激活了
mysqli.dll
(和 mysql.dll:删除/etc/php/7.2/cli/php.ini
中的“#”我开始得到 < code>PHP警告:PHP启动:无法加载与
dll
相关的动态库消息我在同一文件中注释掉了mysql(and i).dll
。但直到我在/opt/lampp/etc/php.ini
中注释掉“”,该消息才消失。看起来 XAMPP 读取了
php.ini
文件 。/etc/php/7.2/cli
并在/opt/lampp/etc
的php.ini
中进行修改 (;extension=php_pdo_mysql. dll 在“;”重新启动 Apache 后不再有任何消息。After
Windows 10 XAMPP
now I installedLAMPP (XAMPP)
on Ubuntu.Windows XAMPP
had 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).I confused and activated
mysqli.dll
(and mysql.dll: erase "#" in/etc/php/7.2/cli/php.ini
I started to get the
PHP Warning: PHP Startup: Unable to load dynamic library
message related todll
. I commented outmysql(and i).dll
in the same file but the message didn't go away up until I commented out " " in/opt/lampp/etc/php.ini
.Looks like XAMPP reads
php.ini
file from/etc/php/7.2/cli
and makes modification inphp.ini
of/opt/lampp/etc
. (;extension=php_pdo_mysql.dll after ";" restarted Apache and no more any message.取消注释 php.ini 中的
extension_dir = "ext"
对我有用。我正在使用 WindowsUncomment
extension_dir = "ext"
in php.ini worked for me. I am using Windows'C:/PHP/5.2.13/ext\php_mcrypt1.dll'
我想说你的 php.ini 上有一些拼写错误(额外的 1)。也许您正在加载与您期望的不同的 php.ini(请参阅 php.ini 的输出以确保)。
除此之外,请确保 php_mcrypt.dll 和 PHP:
链接到相同的 VC 运行时库(通常为 VC6 的 msvcrt.dll 或 VC9 的 msvcrt90.dll) - 为此使用例如依赖项遍历器
都是调试版本还是发布版本
两者都启用了 ZTS 或禁用了 ZTS
对于依赖于其他库 (DLL) 的库,请确保它们可用(例如与扩展位于同一目录中)
如果上述前三个条件中的任何一个不满足,PHP 应该给你错误提示,但我还是写了这些,因为我不确定 PHP 5.2。
'C:/PHP/5.2.13/ext\php_mcrypt1.dll'
I'd say there's some typo on your php.ini (the extra 1). Perhaps you're loading a different php.ini from what you expect (see the output of php.ini to make sure).
Other than that make sure that php_mcrypt.dll and PHP:
Were linked to the same VC runtime library (typically msvcrt.dll for VC6 or msvcrt90.dll for VC9) – use e.g. the dependency walker for this
Are both debug builds or both release builds
Both have ZTS enabled or ZTS disabled
For libraries that depend on further libraries (DLLs), make sure they are available (e.g. in the same directory as the extension)
PHP should give you meaning errors if any of the first three conditions above is not satisfied, but I wrote those anyway because I'm not sure for PHP 5.2.
从 C:\xampp\php\php.exe 我得到
我解决了通过注释掉
C:\xampp\php\php.ini
;扩展名=
From C:\xampp\php\php.exe I got
I solved by commenting out
C:\xampp\php\php.ini
;extension=
当我尝试将 php 与 sql server 一起使用时,当我添加 sqlsrv 库时,我遇到了同样的问题...它给了我错误,经过几天的研究,我了解到微软在这种情况下不支持 x64 那么什么我所做的是安装 laragon x86 并使用相应的库。我希望它能有所帮助
I had the same problem when I tried to use php with sql server, when I added the sqlsrv libraries ... it gave me the error, after several days of researching there, I understood that microsoft does not support x64 in this case so what I did was install laragon x86 and use the corresponding libraries. I hope it helps with something
转到系统环境变量并设置 php ext dir 路径,因为
基本上它是找到 ext 目录,然后找到它的文件,但无法找到文件,因为 php 路径设置为不同。
Go to system env variable and set the php ext dir path as
basically it's finding the ext directory and then locating it's file but it's unable to find the files becuase php path is set as different.
看看架构(arm64,amd64,...)!
我在 macOS 上的 lando (docker DEBIAN 11) 中使用 pdflib for php 遇到了这个问题。
问题是我的 php_pdflib.so 副本是为 linux/amd64 打包的,但在 docker 中我运行的是 Debain arm64 版本。
因此,解决方案是为正确的架构使用正确的包:)
在 Debian(基于)linux 上,您可以通过以下方式找到您的架构师
您还可以通过以下方式分析您的共享对象(.so 文件):
Look at the architecture (arm64, amd64, ...) !
I ran into this problem with pdflib for php in lando (docker DEBIAN 11) on macOS.
The problem was that my copy of php_pdflib.so was packaged for linux/amd64 but in docker I was running Debain arm64 version.
So thew solution is to use the right package for the right architecture :)
On Debian(-based) linux you can find out your architect with
Also you can analyze your shared object (.so-file) with: