Installing a current CouchDB (and Erlang) from source on Ubuntu 8.04 LTS

Two weeks ago I had quite a hard time getting CouchDB up and running on my VPS, but with some help from Jonathan and Lars it finally worked. My main problem was that Erlang wasn’t configured with SSL support and that the CouchDB version I was using (0.11.0) did not play nice with the latest Erland (R14A), so that I had to get CouchDB from the SVN repository. Now that CouchDB 1.0 is here, I thought it might be a good opportunity to summarize the steps I had to take to install the latest Erlang and CouchDB 1.0 on my Ubuntu Hardy system…

UPDATE: Here is a gist that looks like there is a more hassle-free way to do the installation, please try it first and see the rest of this tutorial as a reference point if the gist does not work out for you.

I usually keep my source installs at /usr/local/src/, your milage may vary, adjust the steps accordingly.

Installing the dependencies

First of we got to install the dependencies for Erland and CouchDB:

$ sudo apt-get install -y automake autoconf libtool help2man
$ sudo apt-get install -y build-essential erlang libicu-dev
$ sudo apt-get install -y libmozjs-dev libcurl4-openssl-dev
$ sudo apt-get install -y openssl libssl-dev

Installing Erlang

Download and unpack the current Erlang version, in my case it’s R14A:

$ cd /usr/local/src
$ wget
$ tar xzf otp_src_R14A.tar.gz
$ cd otp_src_R14A

Maybe you would like to see the config options and need to checkout which openssl should be used:

$ ./configure -h
$ which openssl
$ ./configure --with-ssl=/usr/include/openssl/
$ make
$ sudo make install

Once you installed Erlang, check whether its cryptography library (OpenSSL) are functioning correctly.

$ erl
Erlang R14A (erts-5.8) …

Eshell V5.8  (abort with ^G)
1> crypto:start().
2> q().

Installing CouchDB

Download and unpack the current CouchDB version, in my case it’s 1.0:

$ cd /usr/local/src
$ wget
$ tar xzf apache-couchdb-1.0.0.tar.gz
$ cd apache-couchdb-1.0.0

Here you might like to see the config options to and export some of the variables:

$ ./configure -h
$ export ERL=/usr/local/bin/erl
$ export ERLC=/usr/local/bin/erlc
$ ./configure --with-erlang=/usr/local/lib/erlang/usr/include/
$ make
$ sudo make install

For security reasons it makes sense to have a separate couchdb user that runs the process, go ahead and create it:

$ sudo adduser --system \
        --home /usr/local/var/lib/couchdb --no-create-home \
        --shell /bin/bash \
        --group --gecos "CouchDB" couchdb

You will also have to give this user access to some directories:

$ sudo chown -R couchdb:couchdb /usr/local/etc/couchdb
$ sudo chown -R couchdb:couchdb /usr/local/var/lib/couchdb
$ sudo chown -R couchdb:couchdb /usr/local/var/log/couchdb
$ sudo chown -R couchdb:couchdb /usr/local/var/run/couchdb

… and change the permissions for the directories:

$ chmod -R 0770 /usr/local/etc/couchdb
$ chmod -R 0770 /usr/local/var/lib/couchdb
$ chmod -R 0770 /usr/local/var/log/couchdb
$ chmod -R 0770 /usr/local/var/run/couchdb

After that, verify that it finally works:

$ couchdb
Apache CouchDB is running as process …, time to relax.
$ curl -X GET
$ /usr/local/etc/init.d/couchdb start
 * Starting database server couchdb


If CouchDB does not work and it does not write into the log it is likely a permission problem, see if the couchdb directories belong to the couchdb user and that the permissions are set correctly.

Another thing that occured to me was an error that resulted from still having leftovers from previous installations at /usr/lib/couchdb/erlang/lib. Older version, especially of mochiweb-r97 or couchdb can lead to “Bad Request” errors, so clean up the erlang lib directory.

iPhone app for GitHub


is GitHub in your pocket: The go to app for staying up to date with your projects on your iPhone, and iPod Touch.
It is