MongoDB on OS X with the stock PHP installation
This article is part of the DZone NoSQL Resource Portal, which is brought to you in collaboration with Neo Technology and DataStax. Visit the NoSQL Resource Portal for additional tutorials, videos, opinions, and other resources on this topic.
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.
MongoDB
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:
extension=mongo.so
A quick sudo apachectl restart and phpinfo() shows this:
All done! You can now get at MongoDB from your PHP scripts.
Neo Technology and DataStax are leading the charge for the NoSQL movement. You can learn more about the Neo4j Graph Database in the project discussion forums and try out the new Spring Data Neo4j, which enables POJO-based development. You can also see how Apache Cassandra, a ColumnFamily data store, is pushing the boundaries of persistence with cloud capabilities and deployments at SocialFlow and Netflix.- Login or register to post comments
- 2382 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)




