Friday, September 30, 2011

Mongo DB installation with PHP on Wamp Server

This is a quick guide to installing MongoDB.

First download it from http://www.mongodb.org/downloads

Then create a folder structure like the following:
mongodb/
mongodb/bin/
mongodb/data/
mongodb/data/db/
mongodb/logs/

Then Extract the executable files from the donwloaded archive in the bin folder

Open the command line (search cmd.exe and run as admin in Win 7)

CD to the bin directory you put the executables in and run the command:

mongod --logpath C:\mongodb\logs\error.log --logappend --dbpath C:\mongodb\data\db --directoryperdb --install

Make sure you replace the log and db paths with the path to the corresponing folders you created previously.

In reality the folder structure is flexible as long as you have the exe files in the same disk as windows since it doesn't allow you to run a service from another disk (or at least I think so).

Add the bin path to your PATH so you can run mongo from any folder.

Now download the PHP extension from here. You want the Thread Safe version (VC6ts for apache if applicable).

Put the php_mongo.dll file under : wamp\bin\php\php5.3.8\ext

Exit WAMP server if running, start up again and check php>php extension>php_mongo

Restart all services

Done!