Wednesday, July 20, 2011

Installing MongoDB on WampServer

Installing mongodb on Wampserver is more difficult than on LAMP. But, I will give a tutorial about it, as easy as possible. Please follow these steps :
Requirement : you have installed newest WampServer

Follow these steps and each step carefully

  1. Download MongoDB http://www.mongodb.org/downloads
  2. Extract it on specific folder. I suggest you to extract that on bin directory. So, I created it first before extracting that files.
    • Open Start > Run > cmd
    • type this command : cd C:\wamp  (assume that you install WampServer on that folder, you free to change directory like cd DRIVE:\YOUR_FOLDER)
    • cd bin
    • mkdir mongodb
    • mkdir data
    • cd data
    • mkdir db
    • cd..
    • mkdir bin
    • mkdir logs
  3. After you created that folders, you should extract it in folder. i.e: C:\wamp\bin\mongodb\bin
  4. OK. Now it's time to download mongodb drivers for PHP. You can download it in http://github.com/mongodb/mongo-php-driver/downloads
  5. Open mongo-1.1.4.zip, click folder mongo-1.1.4-php5.3vc6ts
  6. Extract php_mongo.dll to C:\wamp\bin\php\php5.3.5\ext
  7. Ok, back to C:\mongodb\bin folder via cmd (cd C:\mongodb\bin)
  8. type this command:
    mongod --logpath C:\wamp\bin\mongodb\logs\error.log --logappend --dbpath 
    C:\wamp\bin\ mongodb\data\db --directoryperdb --install
  9. go to C:\wamp\bin\mongodb\ by windows explorer.
    Create new batch file named startmongo.bat
    type this : net start "MongoDB"
    That file is for starting mongodb service, if windows doesn't start the service
  10. Congratulation. You just have installed mongodb on wampserver
Note: If you find any errors or you just confused about that steps, any question open in this comment.
Sorry for bad english. If you want to make errata for this article, please private message me

9 comments:

  1. awesome....thanks alot

    ReplyDelete
  2. mongod --logpath C:\wamp\bin\mongodb\logs\error.log --logappend --dbpath

    C:\wamp\bin\ mongodb\data\db --directoryperdb --install

    gives me an unrecognised command error in the command line

    ReplyDelete
  3. You have to enter it with out the "Enter" space between:

    bpath " here is an enter that you have to delete" C:\wa .....


    or just copy this :

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

    Good luck

    Troy ;)

    ReplyDelete
  4. when i run this command net start "MongoDB" it gives me error (service name is invalid) i am running net start "MongoDB" command in C:/wamp/bin/mongodb

    ReplyDelete
  5. i am getting below error when i am trying to install it with my local wamp server.

    Mon May 13 10:50:27.963
    Mon May 13 10:50:27.963 warning: 32-bit servers don't have journaling enabled by
    default. Please use --journal if you want durability.
    Mon May 13 10:50:27.963
    Mon May 13 10:50:27.963 Trying to install Windows service 'MongoDB'
    Mon May 13 10:50:27.963 Error connecting to the Service Control Manager: Access
    is denied. (5)

    ReplyDelete
    Replies
    1. You have to run cmd.exe as an administrator. For windows 7: Start --> search for cmd.exe --> right-click --> Run As Administrator.

      Delete
  6. c:\wamp\bin\mongodb>mongod --logpath C:\wamp\bin\mongodb\logs\error.log --logapp
    end --dbpath C:\wamp\bin\ mongodb\data\db --directoryperdb --install
    'mongod' is not recognized as an internal or external command,
    operable program or batch file.

    ReplyDelete
  7. Hi

    As per your blog instruction i am trying to install MongoDb on wampserver but while executing program gives following error :

    "Fatal error: Class 'Mongo' not found in C:\wamp\www\test\index.php on line 19"

    Could you please help me?

    Thanks

    ReplyDelete