Installing CouchDB on Mac OS 10.6 with MacPorts

July 9, 2010 4 Comments by Richard

CouchDB

If you don’t know what CouchDB is, well, there are a lot of other places where you can find that out better than I could explain it.  Google it, my friends, google it.

Harder than it should be

Installing CouchDB with MacPorts should really be as easy as typing “sudo port install couchdb”.  Unfortunately, at least as of the date this was posted, it is not that easy.  The problem is that CouchDB is written in erlang, and erlang has been updated in macports to be a newer version than CouchDB 0.11 (the current stable version) supports.

I have written a post previous to this one about how to downgrade that.  Please read that and do it before proceeding with these instructions.  If you don’t — it just won’t work.

Installing CouchDB

$ sudo port install couchdb
--->  Computing dependencies for couchdb
--->  Fetching couchdb
--->  Verifying checksum(s) for couchdb
--->  Extracting couchdb
--->  Configuring couchdb
--->  Building couchdb
--->  Staging couchdb into destroot
--->  Installing couchdb @0.11.0_0
--->  Activating couchdb @0.11.0_0
########################################################################
# Changes in CouchDB 0.10.0 make 0.9.1 database files incompatible.
# See http://wiki.apache.org/couchdb/BreakingChanges for details
#
# Run the following command to install the CouchDB launchd
# startup item in order to start and re-start service automatically:
#
# sudo launchctl load -w /Library/LaunchDaemons/org.apache.couchdb.plist
########################################################################
--->  Cleaning couchdb

Don’t be alarmed; even though it says 0.10.0 as the version in the notice, that is a warning about an upgrade that (if this is a new install) doesn’t apply to us.

Add missing files

There are a couple of directories that CouchDB scans for configuration files that aren’t created by default.  We’ll create those now (this shouldn’t be critical, but it does prevent warnings.)

$ sudo mkdir /opt/local/etc/couchdb/default.d
$ sudo mkdir /opt/local/etc/couchdb/local.d

Test the configuration

$ sudo -u couchdb couchdbPassword:
Apache CouchDB 0.11.0 (LogLevel=info) is starting.
Apache CouchDB has started. Time to relax.
[info] [<0.31.0>] Apache CouchDB has started on http://127.0.0.1:5984/

If you don’t see this, try to read the error message and figure out what went wrong.  The most common problems I’ve seen deal with permissions issues, usually on /opt/local/var/log/couchdb and /opt/local/var/lib/couchdb

Start automagically

The notice above gives you a launchctl command to load the LaunchDaemon plist file; you don’t need that.  There is a much easier way:

$ sudo port load couchdb
$ curl http://127.0.0.1:5984
{"couchdb":"Welcome","version":"0.11.0"}

And we’re done!  As the couch people say, Time to relax.