Hello, I’m a web craftsman with a passion for the modern web. I build web applications and play with social services and communities.

November 6, 2011 at 4:29 pm

There is still plenty of interest in my old article “Develop memcached web apps with XAMPP under Mac OS X” so I decided to write a little follow up.

XAMPP for OS X hasn’t seen any updates in quite a while so I decided to go with MAMP after upgrading to Mac OS X Lion (10.7.2 as of now). Quite ironic since I originally changed from MAMP to XAMPP because of the lack of updates from MAMP. However, both are quite similar when it comes to installing extensions from pecl or pear so you may have some luck applying the following steps to either dev environment.

Also while I am installing the mongo driver for php here, the very same steps should work for other pecl packages such as memcache, uploadprogress or xdebug. So let’s get started!


  • Install XCode (I’m on 4.2 at the moment)
  • Install MAMP (2.0.5)
Install MongoDB if you haven’t done so yet: (I’m using homebrew for that, it’s the fastest way to get MongoDB running)
  1. $ brew install mongodb
  2. Start the MongoDB server
    $ mongod

Now it’s time to install the mongo php extension:

  1. Download the matching version of the php source code from php.net (MAMP 2.0.5 comes with PHP 5.3.6)
  2. Create an include-folder in your MAMP php installation
    $ mkdir /Applications/MAMP/bin/php/php5.3.6/include
  3. Extract the php source code into that new folder. The extracted folder is called php-5.3.6.
  4. Rename that folder to just php, then the php source code should be located here:
  5. Change into that directory and configure php:
    $ cd /Applications/MAMP/bin/php/php5.3.6/include/php
    $ ./configure
  6. MAMP comes with a weird pear config file that causes issues, let’s remove it:
    $ rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
  7. Now install the mongo driver with pecl:
    $ cd /Applications/MAMP/bin/php/php5.3.6/bin
    $ ./pecl install mongo
  8. Activate the extension in your php.ini:

And that’s all. From now on you only need the last two steps to install other extensions.

8 responses to “Develop MongoDB web apps with MAMP under Mac OS X”

  1. Stennie says:

    Note: in step 7, you may have to run `sudo ./pecl install mongo` depending on your directory permissions.

  2. Andrew says:

    Brilliant setup guide, thanks

  3. Mattias says:

    Thanks! Just wanted to add that this fails if you haven’t installed autoconf.

    brew install autoconf

    Found this tip at http://stackoverflow.com/questions/9322742/php-autoconf-errors-on-mac-os-x-10-7-3-when-trying-to-install-pecl-extensions


  4. SinanMB says:

    Thank you so much for the tutorial and the useful comments !

  5. Maciej says:

    I had a problem with the step 5. When I run configure, I got an exception about iconv saying that I should run configure with this option: “–with-iconv=”.
    After running this command:
    xcode-select –install
    and reruning configure the exception was gone. The rest worked just fine.

  6. Salam says:

    Hey your tualirtos are great..Are you going to do any other tualirtos besides forums? I would like 1 where users can chat like a chat room.I tried going through the tualirtos and always something comes up while I am doing it, can you post the full source for all the files please?

  7. Hey, that’s a clever way of thinking about it.

  8. Mabel says:

    Thanks for writing such an eaet-to-undsrsyand article on this topic.

Leave a Reply