> ## Content Index
> Fetch the complete content index at: https://toodlepip.co.uk/llms.txt
> Use this file to discover other available public pages before exploring further.

# Installing Mongo and Mongo-PHP on Mac OSX Mavericks with MAMP
- URL: https://toodlepip.co.uk/installing-mongo-mongo-php-mac-osx-mavericks-mamp/
- Published: 2014-06-05T23:56:16.000Z
- Updated: 2014-08-17T00:01:41.000Z
- Author: Sam Michel
- Tags: Geekery, mongo, mongo-php, mongodb, nosql, php, xcode, #wp, #wp-post, #Import 2026-10-23 15:06

<tl;dr> A brief and thoroughly geeky blog post. If you’re not tinkering with Mongo on a Mac, best click away now </tl;dr>

Are you wanting to tinker with the fancy schmancy NoSQL database Mongo and you’re running MAMP on your Mac? Should be a doddle to install, right? Erm, not so much.

In case anyone hits the same problem, here’s how I got it working…I’m using the [brew package manager](http://brew.sh/?ref=toodlepip.co.uk) to make life easier and install packages. Download and install it from [http://brew.sh/](http://brew.sh/?ref=toodlepip.co.uk)

## Step 1 – Install Mongo

brew install mongodb

Easy, peasy. Let’s not get ahead of ourselves, this is where it gets tricky. Thanks to [Daniel Farrelly for the pointers in his blog post](http://blog.jellystyle.com/post/37099202581/installing-php-extensions-with-mamp?ref=toodlepip.co.uk).

## Step 2 – Install Autconf & Grab Xcode

brew install autoconf

We’ll need this later on. I’m pretty sure you’ll need Xcode, too. It’s a free download, fire up the *App Store*, search for Xcode and install it. Bit of a beast, so time to grab a brew (caffeinated or alcoholic, your choice).

## Step 3 – Download and Install PHP Source

I’m using PHP 5.5.3\. How’d I find out? Easy. Start your *MAMP application*, click on *Preferences* and select the *PHP* tab. You’ll see which version you’re running. It’ll look something like this image.

![MAMP PHP Preferences](https://toodlepip.co.uk/content/images/toodlepip-wpengine-com/wp-content/uploads/2014/06/screen-shot-2014-06-06-at-00-21-11-e1402010718260.png)

You’ll need the PHP source in order to compile the mongo-php database driver. The sources used to be available from the MAMP website, but I couldn’t find them anywhere.

Find the correct source from [http://www.php.net/releases/](http://www.php.net/releases/?ref=toodlepip.co.uk), in this case I’m after 5.5.3, so let’s download it:

wget http://museum.php.net/php5/php-5.5.3.tar.gz

Unzip the file and you’ll get a new folder *php-5.5.3*. Move the contents of this folder – brace yourselves – into the correct folder in the MAMP directory. You’re looking for the correct version number, in this instance it’s:

cd /Applications/MAMP/bin/php/php5.5.3/  
mkdir include  
cd include  
mkdir php

Now copy the contents of the unzipped file into this new folder */Applications/MAMP/bin/php/php5.5.3/include/php*. The install process requires header files, so you need to run:

cd /Applications/MAMP/bin/php/php5.5.3/include/php  
./configure

Thanks to [Sven Loth for his comment](https://thomashunter.name/blog/getting-the-php-mongodb-driver-installed-with-mamp-on-os-x/?ref=toodlepip.co.uk#comment-286) on this post that highlighted this step.

## Step 4 – Build & Install mongo-php Driver

Yeah, let’s build this sucker. This needs to be done with the right version of *pecl* for the version of PHP you’re using with MAMP. Again, I’m using 5.5.3, but change the version number for your version and it should work.

cd /Applications/MAMP/bin/php/php5.5.3/bin  
sudo pecl install mongo-php

This’ll take a few minutes, but fingers crossed, it *should* work.

Additional step: if PHP isn’t included in your PATH, you might need to add it. Thanks to [Pascal Rieger](https://www.linkedin.com/pub/pascal-rieger/18/632/40?ref=toodlepip.co.uk) for pinging this info over:

export PATH=/Applications/MAMP/bin/php/php5.x.x/bin:$PATH

## Step 5 – Add mongo.so Extension to php.ini

Another gotcha here. MAMP has a whole bunch of php.ini files, one for each version of php. Some are used, some are overwritten. Thanks to [this forum post](http://forum.mamp.info/viewtopic.php?t=4886&ref=toodlepip.co.uk#p13148), we know which one to use: */Applications/MAMP/conf/php5.5.3*.

In the *php.ini* file, look for the extensions, the section will start with *; Extensions* – at the end of the section add:

extension=mongo.so

## Step 6 – Restart MAMP

Yup, do that to load up the new extension and test it’s working, this’ll do the job:

<?php  
phpinfo();  
?>

Scroll down the page and you should see a mongo section, something like this:

![php mongo config](https://toodlepip.co.uk/content/images/toodlepip-wpengine-com/wp-content/uploads/2014/06/screen-shot-2014-06-06-at-00-42-28-e1402011887562.png)

and that, should be that. Hope it works. Any tips, problems, etc, stick ’em in the comments.

Photo (cc) [Jacob Ehnmark](https://www.flickr.com/people/ehnmark/?ref=toodlepip.co.uk) on [Flickr](https://www.flickr.com/photos/ehnmark/3409529926?ref=toodlepip.co.uk).

---

### Comments from the original blog

*These comments were left on the original WordPress version of this post and are kept for reference. Comments are closed.*

**Jaakko Karhu** · 10 August 2014

Thank you for this tutorial. MongoDB installation has been giving me gray hairs and apparently I haven’t been the only one.

However I noticed during the installation that sudo pecl install mongo-php gave me following error:

parsePackageName(): “php” is neither a valid version nor a valid state in “mongo-php”

invalid package name/package file “mongo-php”

install failed

When I typed “sudo pecl install mongo” I got it working. I’m using Mountain Lion, dunno if it matters.

**Sam Michel (author)** · 17 August 2014

Thanks Jaakko, good tip. I’m on Mavericks so couldn’t test.

**Sam Michel (author)** · 17 August 2014

Cool, glad it helped.

**Anthony** · 19 August 2014

I got the same problem : the package name probably changed. You can browse all PECL packages here : pecl.php.net

**Barno** · 26 October 2014

Thanks ! I had to change ‘sudo pecl install mongo-php’ with ‘sudo ./pecl install mongo’. My Mamp version is 3.0.7.2 and my Php is 5.5.18

**andy** · 12 August 2015

ok, I try to use only ““sudo pecl install mongo” but now the error the shell said:

Configuring for:

PHP Api Version:

Zend Module Api No:

Zend Extension Api No:

autom4te: need GNU m4 1.4 or later: /usr/bin/m4

ERROR: \`phpize’ failed

the error is on phpize….how can I solve it?

**Sam Michel (author)** · 18 August 2015

@andy – sorry, I haven’t look at this for a while, looks like you need to update the version of m4\. I don’t know how to do this off-hand, might be worth looking at Homebrew (brew.sh or something similar to update Unix utils.

**Damián Fernández** · 24 January 2016

Thanks Sam, I tried a lot of guides but only with this, I have could configure succesfully!!

**Sam Michel (author)** · 24 January 2016

Oh cool. Glad it worked, bit dated now, relieved it still works.

**Mirco** · 26 January 2016

good tutorial Sam…for Italians advice, is possible, enricoguida.it