William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

Install MongoDB with Windows XAMPP

Install MongoDB with Windows XAMPP

I found a useful article How to install MongoDB to use with XAMPP on Windows when I struggled with the correct version of php_mongo.dll.

Installing MongoDB

  1. Download MongoDB from http://www.mongodb.org/downloads
  2. Extract the archive
  3. Open Command Prompt
  4. Goto mongodb\bin folder
  5. Type to create DB repository and start daemon:
mkdir C:\mongodb\db
mongod.exe --dbpath=C:\mongodb\db

Check your Php version by going to http://localhost/xampp/phpinfo.php
note down the following from the below image
first the php version(here 5.3) then the php extension build (here ts,vc6)

  1. Download MongoDB driver from github.com/mongodb/mongo-php-driver/downloads
  2. Extract driver and copy the dll that matches your php version installed on your xampp (here mongo-1.1.4-php5.3vc6ts) and put to php/ext folder
  3. Open php.ini file
  4. Append this extension=php_mongo.dll, save php.ini file, and then restart your web server.
if every thing went fine then 
  1. Point your browser at localhost and select your language, then phpinfo() from the left menu
  2. Make sure there’s a Mongo section
The core is the ‘PHP Extension Build: API20090626,TS,VC6‘ option in localhost/xampp/phpinfo.php, the ‘TS,VC6‘ here is important for download correct php_mongo.dll version, others corrupt.

Step 3

Try out this example from here http://www.php.net/manual/en/mongo.tutorial.php to test mongodb is working


3 responses to “Install MongoDB with Windows XAMPP

  1. Hirantha 02/25/2013 at 1:57 am


  2. mad 07/17/2013 at 6:36 am

    if step 3 isn’t working try this:

    $collection = $db->phptest;

    • mad 07/17/2013 at 6:37 am

      ? php
      echo “succeeded!”;
      $connection = new Mongo();
      $db = $connection->test;
      $collection = $db->phptest;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: