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.
- Download the PHP source code that matches the version you use with MAMP. I was using 5.3.6, so I downloaded this package.
- Extract it to this folder:
/Applications/MAMP/bin/php/php5.3.6/include/php - Run the following command in this folder:
./configure - The PEAR config file causes some strange issues in MAMP, so remove it:
rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf - Install the MongoDB extension with PECL:
cd /Applications/MAMP/bin/php/php5.3.6/bin./pecl install mongo - 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.