How to install MongoDB on windows and connect it with PHP 7

Struggling to install and connect MongoDB with PHP? Now no worries, I am here to help you out and make your life easier. Come let’s see how its gonna work.

Let us understand and follow the process step by step.

STEP – 1 

The first thing you need to do is install PHP 7.1.33 which works perfectly with mongo 3.2. For this, you need  to download XAMPP from its main website, or you can simply follow click on the below link which downloads automatically.

The download includes the Apache web server, MySQL, PHP, Perl, an FTP server and phpMyAdmin.

After the download, install it in your preferred drive and make sure you have no previously installed xampp. If installed then please uninstall it along with xampp folder. Once installed you can start your xampp server i.e xampp control panel which looks like below. Start Apache and MySQL server  and check if your xampp and PHPMyAdmin are working by typing localhost in URL. If its working Congratulations, you have successfully installed xampp in your system.


STEP – 2

In this step, we are going to install mongo 3.2 which is compatible with PHP 7, as the later versions create some issue which may not connect PHP and mongo.

So before we install mongo we need to go to C Drive and add a folder named data and inside it another folder db(lowercase)  in which all our database are stored.


To install mongo type Download Mongo in the browser and open the first link which will be like mentioned MongoDB Download Center | MongoDB or just follow mentioned link .

In some systems it may redirect this link to another like  which mean the same but this the latest one, also the page will be different for both links as below..

so I will show you the process for both URLs let us call them as LINK1( & LINK2(


For Link 1

You can see 3 tabs named cloud, server, tools. Click on Server and then choose version as 3.2.22 and OS as windows X64 and package as MSI and download. or just download from the below link

For Link 2

You can see 3 tabs named cloud, on-premises, tools. Click on-premises and then scroll down you can see 2 options named  MongoDB Enterprise Server & MongoDB Community Server, click on MongoDB Community Server and on the right side you can see the version, OS choose version as 3.2.22 and OS as windows and package as MSI  which is the default here and download or follow the below link


STEP – 3

This the main step where we are going to connect PHP and MongoDB so follow the steps carefully

After the download is completed install it, meanwhile, we can add MongoDB extension DLL which is PECL file in our xampp and change the php.ini file. so for this go to your xampp => php => ext  and download the below file and add it inside ext folder.

or you can goto the below link and choose compatable file this may be time taking so I suggest you to down from before link. 

After adding the link open php.ini file which will be found in xampp=>php and the php.ini if you are unable to find the file go to your browser and open your http://localhost/dashboard/phpinfo.php file and search for php.ini then copy the link and paste in you file explorer and the file is opened.

Now go to line number 891 and add this line of code extension=php_mongodb.dll  then save the file and restart xampp server and open your phpinfo file and search for mongo and it should show as below if this is done then you successfully connected php with mongo.mongodbphpinfo

To check if your mongo is working then goto C Drive => Program Files OR Program Files (x86) where you can find MongoDB folder open it then server => Bin => 3.2 and click on the above file path and write cmd command prompt is opened and write mongodb(lowercase)  it should appear some like below and again go to the same path and open cmd again and type mongo and it should say connecting to test if it says connection failed then again type mongo, it works then you can write mongo commands to check. Follow the below link to check MongoDB commands.

This is the whole process to connect mongo with PHP. If you like it please share this with your friends who want to install mongo with PHP.


  • If you want to give suggestions to improve my blog please open the below link and submit your suggestions.

  • Want to publish your  Blog / Story / Post then open the below link and submit. We will let your blog publish in our website


2 thoughts on “How to install MongoDB on windows and connect it with PHP 7

Leave a Reply

Your email address will not be published. Required fields are marked *

The maximum upload file size: 2 MB. You can upload: image, document. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded.