IT & Programming

MongoDB installation on WAMP and configuration with PHP

It is not always easy and simple to install MongoDB on WAMP and configure it with PHP to run on window's environment. I hope my experience of installation will help you.

MongoDB Installation

Download latest version of 64 bit mongodb from www.mongodb.org
Run the exe file and copy extracted files to 
C:\wamp\bin\mongodb\mongodb or path where you want to install.
Create following directories at

c:\wamp\bin\mongodb\data\db 
c:\wamp\bin\mongodb\conf
c:\wamp\bin\mongodb\logs
Create file at c:\wamp\bin\mongodb\conf\mongodb.conf and paste below code in it.

# mongodb.conf

# data lives here
dbpath=C:\wamp\bin\mongodb\data\db

# where to log
logpath=C:\wamp\bin\mongodb\logs\mongodb.log
logappend=true

# only run on localhost for development
bind_ip = 127.0.0.1                                                             

port = 27017
rest = true
Create file c:\wamp\bin\mongodb\logs\mongodb.log
Run mongod.exe --install --config c:\wamp\bin\mongodb\conf\mongodb.conf --logpath c:\wamp\bin\mongodb\logs\mongodb.log 
to install and run mongodb as window's service.

mongo.exe is the MongoDB shell, it will be very convenient to add the bin directory 
to your PATH environment variable so that you can simple type mongo at the command line 
regardless of your current working directory. 

Go to My Computer -> Properties -> Advanced system settings -> Environment ->Path 
and add C:\wamp\bin\mongodb\mongodb

Stop mongodb 'NET STOP "Mongo DB"' and then start mongodb 'NET START "Mongo DB"'

PHP Mongo Installation:

Go to 
https://s3.amazonaws.com/drivers.mongodb.org/php/index.html?sort=lastmod&sortdir=asc 
and download "php_mongo-1.6.0RC3" for mongodb version 2.6.6
Unzip the file and copy "php_mongo-1.6.0RC3-5.4-vc9-x86_64.dll" to C:\wamp\bin\php\php5.4.12\ext
Add "extension=php_mongo.dll" to C:\wamp\bin\apache\Apache2.4.4\bin\php.ini
Restart WAMP server and that should be it.

Leave A comment

Email address is optional and will not be published. Only add email address if you want a reply from blog author.
Please fill required fields marked with *