Robin van der Vleuten

Install Mongo extension in MAMP with PECL

As you may have guessed from my previous post, I was using MAMP on a Mac. I liked the Pro interface more than tools like XAMPP, but installing PEAR or PECL extensions was not obvious.

Here is how I installed the MongoDB extension. The same approach should work for other extensions too.

  1. Download the PHP source code that matches the version you use with MAMP. I was using 5.3.6, so I downloaded this package.
  2. Extract it to this folder: /Applications/MAMP/bin/php/php5.3.6/include/php
  3. Run the following command in this folder: ./configure
  4. The PEAR config file causes some strange issues in MAMP, so remove it: rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
  5. Install the MongoDB extension with PECL: cd /Applications/MAMP/bin/php/php5.3.6/bin ./pecl install mongo
  6. Activate the installed extension in your php.ini file: extension=mongo.so

That's it. You can now use MongoDB from PHP applications running through MAMP. Most of these steps came from Matthias Schmidt.