I wonder if I could have found a longer title for this post. Possibly, but I doubt I could come up with one more specific. Honestly installing mongodb on Mac OS X is pretty trivial if you have the MacPorts installed and getting things working with PHP is not very difficult either. What is required is a little planning before you begin.
Obviously if you do not have the MacPorts installed then that should be your first order of business and it will require the current release of Xcode. At this point let’s assume that you do have MacPorts installed and properly updated. Using the ports system will create the database staging area in /opt/local/var/db/mongo, set up the mongodb.log in /opt/local/var/log/mongodb/mongodb.log as well as create the org.macports.mongodb.plist in /Library/LaunchDaemons.
In a terminal window run the following command:
sudo port install mongodb
At this point you can begin to play around with mongo but if you want to build an application you will need to setup a bridge between your favorite language and the DB daemon. In this case I am covering PHP because in the past adding things into the stock version that is bundled with Mac OS X Server can be nothing less than tricky. Fortunately Apple included PECL on Snow Leopard(1) and above. You can check your system by opening the Terminal and typing ‘which pecl’ to reveal the path of the installed utility.
sudo pecl install mongo ... Build process completed successfully Installing '/usr/lib/php/extensions/no-debug-non-zts-20090626/mongo.so' install ok: channel://pecl.php.net/mongo-1.2.6 configuration option "php_ini" is not set to php.ini location You should add "extension=mongo.so" to php.ini
If you are still running the default configuration file then edit /etc/php.ini-defaults and resave as /etc/php.ini. Basically you need to add the following to the end of the ini file. You should also take a moment to examine the file’s timezone setting and set that as well. Simply search for [date] and enter the appropriate entry for your timezone (see note 2 below).
[mongo] extension=mongo.so
Restart Apache and check your work. I simply drop a phpinfo() call in a know working php script and examine the output. You should see something like the following;
As you can see things are pretty straight forward to get things up and running. Now you have the basic web 2.0 tools ready at you fingertips; so get busy designing those cool applications to serve up.
(1) – I will try to verify if earlier versions had PECL installed.
(2) – date.timezone setting example
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = 'America/New_York'
Related articles
- Performing MacPorts Magick (jafdip.com)
- Name Based Vhosting in Mac OS X Snow Leopard Server (jafdip.com)
- Advanced Mac OS X Shell Scripting (jafdip.com)
- FreeBSD 9.0 beta1 Announced Today (BSDNews.net)
adidas beckenbauer asos says
I was wondering if you ever thought of changing the layout of your blog? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or two pictures. Maybe you could space it out better?
Mikel King says
We are in fact slowly evolving the design.
Mikel King says
As per my previous reply. Yes. We are working on this.
jc superstar says
Woah! I’m really enjoying the template/theme of this blog. It’s simple, yet effective. A lot of times it’s tough to get that “perfect balance” between superb usability and appearance. I must say you have done a fantastic job with this. In addition, the blog loads very fast for me on Opera. Outstanding Blog!
BSD News (@bsdnewsnetwork) says
Thank you for publishing this.