- Published on
How to Setup MongoDB on MAMP in 5 minutes
- Authors
- Name
- Ashik Nesin
- @AshikNesin
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
mongod
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 php.net and extract it in /Applications/MAMP/bin/php/php7.x.x/include/php
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 **extension=mongodb.so **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.