php PHP启动无法加载动态库php_mongo.dll

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

PHP Startup Unable to load dynamic library php_mongo.dll

phpmongodbdll

提问by blitzen12

I'm a beginner for this. I'm trying to install mongodb driver on php.

我是这个的初学者。我正在尝试在 php 上安装 mongodb 驱动程序。

Platform: Windows 8.1 64bit.
PHP 5.5.9
Apache/2.4.7

Followed the instruction here:http://php.net/manual/en/mongo.installation.php#mongo.installation.windows

按照此处的说明进行操作:http: //php.net/manual/en/mongo.installation.php#mongo.installation.windows

I've tried all php_mongo.dll file with VC11 and put in php/ext folder. and added extension=php_mongo.dllin php.ini file but when I tried to start apache in xampp controller I got an error.

我已经用 VC11 尝试了所有 php_mongo.dll 文件并将其放入 php/ext 文件夹中。并添加extension=php_mongo.dll到 php.ini 文件中,但是当我尝试在 xampp 控制器中启动 apache 时出现错误。

    Php Startup: Unable to load dynamic library
  'C:\xampp\php\ext\php_mongo.dll' -%1 is not a valid Win32 application.

I've already check my VC compilator version inside phpinfo() and it's stated there MSVC11with architecture: x86.

我已经在 phpinfo() 中检查了我的 VC 编译器版本,并且在那里MSVC11architecture: x86.

it would be nice if someone can help me. Thanks. appreciate it.

如果有人可以帮助我,那就太好了。谢谢。欣赏它。

回答by Kimutai

Make sure you download the correct .DLL for your PHP installation. Good chance you're running apache x86, so download an x86 php_mongo.dll. Also if you're running PHP as an Apache module, make sure you pick the thread safe (ts)one and also pick this type of dllthat matches the PHP version you're running.

确保为 PHP 安装下载正确的 .DLL。很有可能你正在运行 apache x86,所以下载一个 x86 php_mongo.dll。此外,如果您将 PHP 作为 Apache 模块运行,请确保您选择thread safe (ts)一个,并选择dll与您正在运行的 PHP 版本相匹配的这种类型。

The versions must match or else you will get a php startup error. Find these Mongo DLLs here.

版本必须匹配,否则您将收到 php 启动错误。在此处找到这些 Mongo DLL 。

I did this then I got an error libsasl.dllnot found. I simply copied the libsasl.dllfound in my PHP installation directory to the Apacheinstallation directory (where httpd.exeis found). Then I restarted my Apache and it worked!

我这样做了,然后我libsasl.dll发现了一个错误。我只是将libsasl.dll在我的 PHP 安装目录中找到的复制到Apache安装目录(httpd.exe找到的位置)。然后我重新启动了我的 Apache 并且它工作了!

回答by bzzhuh

For anyone googling this in 2017, the PECL Package has been updated and is now found at http://pecl.php.net/package/mongodb/1.2.9/windows

对于 2017 年使用谷歌搜索的人,PECL 包已经更新,现在可以在http://pecl.php.net/package/mongodb/1.2.9/windows找到

and use:

并使用:

extension=php_mongodb.dll 

instead of:

代替:

extension=php_mongo.dll

回答by Stephen Curry

Copy C:\xampp\php\libsasl.dllto C:\xampp\apache\bin\, restart Apacheand enjoy.

复制C:\xampp\php\libsasl.dllC:\xampp\apache\bin\,重新启动Apache并享受。

回答by user3799019

If you are still having problems after doing the above, do try older version drivers instead.

如果您在执行上述操作后仍然遇到问题,请尝试使用旧版本的驱动程序。

That is what worked for me on for my XAMPP/ PHP 5.5 on windows 8.

这就是我在 Windows 8 上的 XAMPP/PHP 5.5 上的工作。

Older drivers can be found here: https://s3.amazonaws.com/drivers.mongodb.org/php/index.html

可以在此处找到较旧的驱动程序:https: //s3.amazonaws.com/drivers.mongodb.org/php/index.html

New drivers can be found here: http://pecl.php.net/package/mongo/1.5.5/windows

可以在这里找到新的驱动程序:http: //pecl.php.net/package/mongo/1.5.5/windows

You may also want to visit : https://serverfault.com/questions/563867/mongodb-unable-to-load-driver-on-php

您可能还想访问:https: //serverfault.com/questions/563867/mongodb-unable-to-load-driver-on-php

回答by manian

This is normally because we use 64 Bit supported DLL file 64 Bit system. But the wamp/xampp architecture could be 32 Bit. We need to use based on the wamp/xampp architecture not the windows architecture. So, try to find relevant version of DLL file to the wamp/xampp architecture. The solution in the below link worked like a charm to me,

这通常是因为我们使用 64 位支持的 DLL 文件 64 位系统。但是 wamp/xampp 架构可以是 32 位。我们需要使用基于 wamp/xampp 架构而不是 windows 架构。因此,尝试找到与 wamp/xampp 架构相关的 DLL 文件版本。下面链接中的解决方案对我来说就像一个魅力,

http://grokbase.com/t/gg/mongodb-user/151xpk3fkr/php-5-6-3-with-mongodb-driver-unable-to-load-dynamic-library-not-a-valid-win32-application

http://grokbase.com/t/gg/mongodb-user/151xpk3fkr/php-5-6-3-with-mongodb-driver-unable-to-load-dynamic-library-not-a-valid-win32-应用

This link helps you to find the wamp/xampp architecture, https://stackoverflow.com/a/22454865/4874281

此链接可帮助您找到 wamp/xampp 架构,https://stackoverflow.com/a/22454865/4874281

回答by Luke P. Issac

After doing all the steps as mentioned in previous comments xampp may not be able to load the ".dll" file. Just ensure to add the path of the ".dll" file's folder to the environment variable as a system variable path.

完成前面评论中提到的所有步骤后,xampp 可能无法加载“.dll”文件。只需确保将“.dll”文件文件夹的路径作为系统变量路径添加到环境变量中。

I was facing same issue, then after adding the path of the ".dll" file's folder to the environment variable as a system variable path, it worked. It is then able to find the file.

我遇到了同样的问题,然后在将“.dll”文件文件夹的路径作为系统变量路径添加到环境变量后,它起作用了。然后它能够​​找到该文件。

At the end that was the only step which was stopping xampp to load the ".dll" file, although it was present in that folder. Often people miss this step as it is no where pointed out clearly.

最后,这是停止 xampp 加载“.dll”文件的唯一步骤,尽管它存在于该文件夹中。通常人们会错过这一步,因为它没有明确指出的地方。