Setup MongoDB with WAMP

We will learn how to setup MongoDB with WAMP.

Requirement: Wamp Server is already installed on your Windows (Version wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b) Or latest one

In Order to setup MogoDB with WAMP please follow following steps.

First, we have to download the latest build Mongo DB on MongoDB Official, download the zip file for version

After the file has been downloaded, we have to create some directories.

  • create the Mongo DB base folder under E:\wamp64\bin and named as “mongodb”. You have to create folder in your WAMP install Path.
  • create the Mongo DB version folder under E:\wamp64\bin\mongodb and named as “mongodb-win32-x86_64-2008plus-ssl-3.2.10”.
  • create the following directories under E:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.2.10

Create the file “mongodb.conf” under E:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.2.10\conf, then add this configuration..


# data directory
dbpath=E:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.2.10\data\db


# log directory
logpath=E:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.2.10\logs\mongodb.log
logappend=true


# run on localhost for development
bind_ip = 127.0.0.1
# using port
port = 27017

Extract  the downloaded zip file (In step 1 ) into bin folder.

Open the windows command prompt as administrator privilege and locate it to E:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.2.10\bin.

Execute this command to install Mongo DB as a windows service.


mongod.exe --install --config E:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.2.10\conf\mongodb.conf --logpath

E:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.2.10\logs\mongodb.log
OR


mongod.exe --install --service --config
E:\wamp64\bin\mongodb\folder-with-version\conf\mongodb.conf --logpath
E:\wamp64\bin\mongodb\folder-with-version\logs\mongodb.log --dbpath
E:\wamp64\bin\mongodb\folder-with-version\data\db
OR (If needed)


mongod.exe --reinstall --service --config
E:\wamp64\bin\mongodb\folder-with-version\conf\mongodb.conf --logpath
E:\wamp64\bin\mongodb\folder-with-version\logs\mongodb.log --dbpath
E:\wamp64\bin\mongodb\folder-with-version\data\db

Open “services.msc” and run MongoDB service then start the service. We can set manually or automatically when windows start up.

 

Add Path on Windows Environment Variables :

  1. Right click on My Computer.
  2. Click Advanced system settings.
  3. Click Environment Variables button.
  4. Click PATH on Variable column, then append this path.

;E:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.2.10\bin;

If you are working on PHP5.6.25 then add below one

;E:\wamp64\bin\php\php5.6.25

If you are working on PHP7.0.10 then add below one

;E:\wamp64\bin\php\php7.0.10

Note : adjust the version and take a look the delimiter “;”.

 

Check everything is running well :

Open the windows command prompt as administrator privilege.

Check with this command

c:\> mongo
MongoDB shell version: 3.0.1
connecting to: test
>
> use test;
switched to db test

Add Mongo DB PHP Extension into WAMP Server PHP

I have added version wise php_mongo.dll file. Please choose file as per your PHP version.

  1. Please copy this file into this directory E:\wamp64\bin\php\php5.6.25\ext
  2. Add this line “extension=php_mongo.dll” on the “php.ini” file in this directory E:\wamp64\bin\apache\apache2.4.23\bin\php.ini.
  3. Restart all Wamp Services.
  4. Check the extension is work by clicking Wamp icon -> PHP -> PHP Extensions, and ensure the php_mongo is checked.