Install & Configure MongoDB Driver in XAMPP/WAMP Windows

This tutorial help to install the MongoDB server into windows. I will also let you know the configuration with the PHP server. We will use the MongoDB driver to connect PHP with MongoDB.

MongoDB is a very popular NoSQL database in web development, Here I am creating a series of tutorials about MongoDB with PHP.

I am using windows for the development environment so all the steps are illustrated here for windows. I will cover the following steps regarding MongoDB with PHP.

  1. Installation of MongoDB Server on windows.
  2. Installation of MongoDB driver on xampp.

Steps to install MongoDB Server on Windows

  • Download latest MongoDB 64-bit MSI version for windows .msi file and run.
  • Add bin path (C:\Program Files\MongoDB\Server\3.0\bin) into your environment variable to access MongoDB from the command line.
  • Create data and DB folder under your MongoDB home directory. My installation directory is C, So I have created folder (C:\data\db), as mentioned in MongoDB docs. This is the default directory of mongoDB, so don’t create it anywhere else on the computer.
  • Now open cmd line (C:\user\palam>) and type mongod to start the mongo server, Now you can see a message in the command window – “successfully connected with http://127.0.0.1/27071″
  • Open another cmd line (C:\user\palam>) and type mongo mongo -version and press ‘ENTER’, You will see the installed version of MongoDB.

Mongo Server UI

You can also get web UI of Mongodb as like phpMyAdmin using node module, You can install MongoUI using the below command,
npm i -g mongoui
-g options use to install mongo UI globally, You need to just open the command line and type cmd>mongoui, This command will start mongoui on 3000 port.

You can get all mongodb collections on http://localhost:3001 url, You need to open (http://localhost:3001) on any browser.

Install Mongo Driver on Xampp/Wamp

Let’s follow the below steps to install the MongoDB driver in XAMPP for PHP. Mongo is providing a .dll file to install mongo driver as a PHP extension on xampp windows. There are following steps that need to follow to install the mongo driver extension.

Simple Step to Install Mongo Driver on Xampp/Wamp

  1. Download .dll file from PEAR Directory, please make sure .dll file must be compatible with your PHP version.
  2. Put downloaded .dll file into your PHP extension (\ext) directory, mine xampp location is (D:\xampp\php\ext\).
  3. Enable php_mongo.dll extension from you php.ini file, php.ini file location would be (D:\xampp\php\), Open file and search 'extension=php_mongo.dll', if found remove semi-colon ';' otherwise add 'extension=php_mongo.dll' line to enable mongoDB extension for PHP.
  4. Restart Xampp server, if you will get error ‘mondo dll file can not found’ that means your .dll file is not compatible with your PHP version.
  5. After successful installation, please open your php_info file and search mongo if you found mongo as a module that’s mean you have successfully installed mongoDB driver on your xampp.

Conclusion:

We have configured MongoDB on windows, it’s very simple and easy to install MongoDB on windows. We have integrated the PHP mongo driver with the PHP server as well. I have also started the mongo server using the command line on windows.

Please Post questions and queries using the comment section, I will try my best to solve your problem and concern.

2 thoughts on “Install & Configure MongoDB Driver in XAMPP/WAMP Windows

  1. Update your PEAR DIRECTORY link in order to point to: https://pecl.php.net/package/mongodb

Leave a Reply

Your email address will not be published.