How to Setup MongoDB on MAMP in 5 minutes

September 08, 2016

Setting up MongoDB is little tricky if you are using MAMP. You just need to spend little time to install few dependency and make few tweaks in your system.

Install MongoDB if you haven’t done so yet and configure it. (auto-start mongodb server)

brew install mongodb

And start the server


Let’s get started and install mongodb php extension on MAMP/MAMP PRO

#1 Download PHP source code

We need to download the matching version PHP source from and extract it in /Applications/MAMP/bin/php/php7.x.x/include/php

mongodb mamp php source

And then configure it.

/Applications/MAMP/bin/php/php7.x.x/include/php && ./configure

#2 Install the PHP MongoDB driver

First, we need to set PATH in order to install mongodb driver in the MAMP.

export PATH=/Applications/MAMP/bin/php/php7.0.8/bin:$PATH

Then install the driver

sudo C_INCLUDE_PATH=/usr/local/opt/openssl/include pecl install mongodb

#3 Configure php.ini

Lastly, we need to add ** **in our php.ini

If you are using MAMP PRO and want to edit your php.ini then you can need to go to File -> Edit Template -> PHP and select your php version.

👋 I'm Ashik Nesin • Principal Software Engineer @Chargebee 👨‍💻• I write about web development & behinds the scenes of startup/side projects that I'm building

© 2022 Nesin Technologies LLP