Over a million developers have joined DZone.

MongoDB on OS X with the stock PHP installation

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

MongoDB was mentioned a few times at tek and I said that I wanted to have a look at.

Travis' article, MongoDB: A first look, came out a few days ago and piqued my interest further. Then Matthew sent me some source code that requires it. The stage was set for getting MongoDB working on my Mac.


I use homebrew as a package manager for installing open source bits and bobs like couchdb, git, and hg. Installing MongoDB was simply a case of:

brew install mongodb

Once, installed there's a convenient LaunchAgent plist supplied so that mongodb starts with the computer:

cp /usr/local/Cellar/mongodb/1.4.3-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

And at this point, MongoDB is installed on your Mac and Travis' article and the tutorial work!

The Mongo PHP extension

If you've been following along here for a while, then you'll know that I use the stock PHP that comes with Mac OS X. I've been very happy with it so far and installed Xdebug was easy enough using pecl, so I was hopeful that the mongo extension would be equally simple.

Turns out that it is!

pecl install mongo

Compiles the extension with no problems.

To add it to your PHP install, edit php.ini and add:


A quick sudo apachectl restart and phpinfo() shows this:

All done! You can now get at MongoDB from your PHP scripts.

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.


Published at DZone with permission of Rob Allen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}