PHP startup mongo: Unable to initialize module

拈花ヽ惹草 提交于 2020-01-02 02:38:38

问题


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.

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.

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.


回答1:


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.

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.

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

For example:

Zend Extension Build => API220100525,NTS,VC9

.. would indicate you should use the NTS (Non-threadsafe) 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.



来源:https://stackoverflow.com/questions/13523109/php-startup-mongo-unable-to-initialize-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!