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.
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”.
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.dll in your PHP extension directory.