本文介绍了PHP启动mongo:无法初始化模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为使用 xampp 。我在系统中安装了* mongo_db(1.8.5)*,并在我的系统中安装了xampp-1.8.1-VC9 。为了配置PHP for mongoDB ,我已经下载了* php_mongo.dll *(尝试 VC9线程安全非-thread safe ),并将 .dll 文件粘贴在'../ php / ext'目录中,并添加 extension = php_mongo.dll php.ini 文件中。

I am currently Using xampp for PHP. I installed *mongo_db(1.8.5)* in my system and also installed xampp-1.8.1-VC9 in my system. In order to configure PHP for mongoDB, I have downloaded *php_mongo.dll*(tried both VC9 thread safe and non-thread safe) and pasted the .dll file in the '../php/ext' directory and also added extension=php_mongo.dll in the php.ini file.

现在,当我尝试启动 apache xampp 中显示以下显示信息,即 正在开始。

Now when I try to start the apache in xampp it shows the following display eventhough apache is getting started.

PHP startup mongo: Unable to initialize module
Module compiled with module API : 20090626
PHP compiled with module API : 20100525
These options need to match.

另外我的 .php 代码连接 Mongo 不工作这意味着某处有一些错误。

Also my .php code to connect Mongo is not working. This means there is something wrong somewhere.

我出错了。任何帮助将不胜感激。

Where I am going wrong. Any help would be appreciated.

推荐答案

看起来您正在尝试使用PHP 5.4为PHP 5.3安装一个扩展名;模块API版本需要匹配PHP的版本。

It looks like you're trying to install an extension compiled for PHP 5.3 with PHP 5.4; the module API version needs to match the version of PHP.

如果您下载(例如 php_mongo-1.2.12.zip 是当前的稳定版本),它包括DLL对于多个PHP版本(例如5.2,5.3和5.4)。您需要为系统复制正确的DLL并将其重命名为php_mongo.dll。

If you download the precompiled MongoDB PHP driver from Github (eg. php_mongo-1.2.12.zip is the current stable version) it includes DLLs for multiple PHP versions (eg 5.2, 5.3, and 5.4). You need to copy the correct DLL for your system and rename it php_mongo.dll.

您可以从 phpinfo()输出(或命令行中的 php -i )。检查Zend Extension Build的值。

You can determine the required version from the phpinfo() output on your system (or php -i from a command line). Check the value for "Zend Extension Build".

例如:

Zend Extension Build => API220100525,NTS,VC9

..将表示您应该使用NTS(非线程安全)DLL。

.. would indicate you should use the NTS (Non-threadsafe) DLL.

在64位Windows上,这意味着复制 php_mongo-1.2.12-5.4-vc9-nts-x86_64.dll 到您的PHP扩展目录中的 php_mongo.dll

On 64-bit Windows, that would mean copying php_mongo-1.2.12-5.4-vc9-nts-x86_64.dll to php_mongo.dll in your PHP extension directory.

这篇关于PHP启动mongo:无法初始化模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 15:59