Nojan
Nojan

Reputation: 913

MongoDB php extension not working on windows 7

I want to use MongoDB with PHP5.5 on Wampserver 2.5 but I can't get it working. I've setup MongoDB 2.6.3 config file using this tutorial and ran the mongod.exe --install --config 'config_path' and added the path to enviroment variables and it seems that MongoDB service is installed and is working just fine. I've also copied the thread-safe mongodb php driver into php's ext folder and added the extension=php_mongo.dll to both php.ini files in apache/apache2.4.9/bin/ and php/php5.5.12 folders. When I run wampserver there's a warning sign next to php_mongo extension. The problem is that I've tried installing x64 version of wampserver and MongoDB but didn't make any difference and I don't get any errors in the logs relating to this problem.

I've also read that using the Non-thread-safe version of the driver fixes the problem. But when I use it I get this error while starting wampserver:

The program can't start because php5.dll is missing from you computer.
Try reinstalling the program to fix this problem.

PHP Startup: Unable to load dynamic library
'c:/wamp/bin/php5.5.12/ext/php_mongo.dll' - The specified module could not be found.

Here's the set of software that I'm using:

And just to mention, mongodb in installed in c:\mongodb\ and wampserver is installed in c:\wamp

I appreciate any help on this.

EDIT: Problem didn't go away, so I had to search for another webserver and I found zWamp which is a php/mysql/apache/mongodb stack and it works!

Upvotes: 3

Views: 8248

Answers (7)

Ultranuke
Ultranuke

Reputation: 1885

I also had this problem, this is what I was using:

Windows 10, 64 Bits

Wamp 2.5, 64 Bits

PHP 5.5.12

MongoDB 3.2

The extension appeared in the php extensions list as included but didn't show up in phpinfo, I tried almost all the versions of the mongodb library but solved it in this way:

  1. Updated the WAMP PHP version from 5.5.12 to 5.5.31 (latest), I almost followed the instructions here: Upgrading WAMP PHP, I just followed until the step 5, after adding the new version don't forget to switch to the new version just clicking the WAMP icon->PHP->Version->5.5.31

  2. Added the extension to the php.ini file of my upgraded PHP version, I added it just after the mysqli extension:

    extension=php_mongodb.dll

  3. Copied the MongoDB extension to the /ext folder in my upgraded version of PHP, I used the MongoDB 1.1.2 driver which is the new and updated library, it also depends on your MongoDB version and can be found here: https://pecl.php.net/package/mongodb Check the MongoDB library compatibility here: https://docs.mongodb.org/ecosystem/drivers/php/ for this solution I used the version 1.1.2 for PHP 5.5 Thread Safe (TS) x64 (It is supposed that all the WAMP libs have to be Thread Safe)

  4. I also finally had to copy my edited php.ini file to the Apache folder: wamp\bin\apache\apache2.4.9\bin to get it to work maybe the syslink was pointing to the older one.

Greetings!

Upvotes: 0

Priy Ranjan
Priy Ranjan

Reputation: 119

I used this and worked: php_mongo-1.5.1.zip

After installing mongodb when I was going through this amazon bucket list (https://s3.amazonaws.com/drivers.mongodb.org/php/index.html) for extension dll file. I have taken latest zip file and chosen dll file which shoots for my php version(5.5.12) and architecture(64) its did not worked out. Lastly I tried php_mongo-1.5.1.zip dll(php_mongo-1.5.1-5.5-vc11-x86_64.dll) file its started working mongo extension details can see in phpinfo().

Before starting work in mongodb don't forgot to start mongod server.

Upvotes: 2

Radek
Radek

Reputation: 515

avoid Wampserver 2.5 administration "interface" and simply place it in BOTH php.ini files ... in my case, those are located in

C:\wamp\bin\php\php5.5.12

and

C:\wamp\bin\apache\apache2.4.9

i added the extension as

extension=php_mongo-1.5.1-5.5-vc11-x86_64.dll 

as new line to where other extension=... lines are

(remember to copy the DLL file from driver file you download here https://s3.amazonaws.com/drivers.mongodb.org/php/index.html to folder C:\wamp\bin\php\php5.5.12\ext - i used the 1.5.1 version)

Restart wampserver and it is working fine now, altho Wampserver still shows warning triangle by the mongo .dll in PHP admin section.

Upvotes: 1

Lee
Lee

Reputation: 1

Make sure that you added the PHP installation directory to system environment variable PATH. I'm using Mongo driver v1.5.8 and it's working good. PHP manual page says: "This extension requires the following files to be in the PATH: libsasl.dll" you can find libsasl.dll in the PHP installation directory.

Upvotes: 0

rcsalvador
rcsalvador

Reputation: 79

I´ve had the same problem in Windows 8.1 with Apache 2.4 and PHP 5.5. I tried the lastest version of mongo driver 1.5.5 and 1.5.4 downloaded from AWS "bucket list", but nothing worked. Then I tried version 1.5.1 and all works fine now, the error on apache log has gone and MongoDB support are showed in phpinfo().

Upvotes: 4

user3727117
user3727117

Reputation:

If you are getting warning sign before mongo in php plugin then mongoDB drivers are not loaded in php.ini. Add extension=php_mongo-XX;(.dll file name which you have placed in php/ext folder). Warning sign will go away and mongoDB driver will load in php.

Upvotes: 0

Amol M Kulkarni
Amol M Kulkarni

Reputation: 21629

Make sure you are using the thread safe version of the MongoDB extension. I had faced smae error while using the non-thread-safe versions on windows (WAMP). Just a right .dll file resolved the issue.

To download extension, check the following link: http://www.php.net/manual/en/mongo.installation.php#mongo.installation.windows

Update: there are 4 files please chose the proper one based on your machine config. *-vc11-, *-vc11-nts, *-vc11-x86_64 and *-vc11-nts-x86_64. -vc11-x86_64 worked fine for me.

Upvotes: 0

Related Questions