Install CouchDB on Ubuntu/Debian with Lighttpd

Install CouchDB on Ubuntu/Debian with Lighttpd

Depending on your version of Ubuntu ~ Debian, you may be able to install the latest version of CouchDB via APTITUDE; chances are though, you wont.
As its really not that difficult to install it from scratch we may as well do it from source.

Here we'll cover the installation; basic configuration and how to proxy a sub-domain to your CouchDB.

I'll stick the commands below in order of sequence (how the bloody hell else would you do it?)

Step One: Install all the required crap…

aptitude install automake spidermonkey-bin autoconf subversion-tools libtool help2man build-essential erlang erlang-manpages libicu38 libmozjs-dev wget libicu-dev libreadline5-dev checkinstall

**Note: add sudo to the front of this if you usually use the sudo command.
If your on Ubuntu 8.04 or Intrepid you'll need to have a fiddle after this to get the latest version of erlang or when you download CouchDB, it will tell you to sod off.
To make sure your not one of these people type erl into shell;

[email protected]:/# erl
Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [async-threads:0] [kernel-poll:false]

Eshell V5.6.5  (abort with ^G)

If your version is 5.6.5 it will work fine with version 0.11.0 at least; If you have any difficulties it will tell you which version you need.
Now if its less than 5.6.5 lets update;

nano /etc/apt/sources.list 

And comment out your normal "universe" then add the latest…

#deb hardy main restricted universe
deb jaunty universe

Then update your aptitude; then upgrade erlang

apt-get update
apt-get upgrade erlang

Check the version again (as we did a moment ago) if your on 5.6.5, feel free to re-edit your sources.list file commenting out jaunty for hardy.
Ubuntu 8.0.4 is the STABLE server release and is under LONG TERM SUPPORT; so those instructions will apply to many people :)

Step Two: Get the latest version of CouchDB onto your server

Go to and copy the url for the latest version. Then unzip it.

tar -xzvf apache-couchdb-0.11.0.tar.gz

Step Three: Create a user for your settee

sudo adduser --no-create-home --disabled-password --disabled-login couchdb

Step Four: Lets install CouchDB

Good shell; lets go on. Within your extracted tar file…
You may want a beer at this point.

cd apache-couchdb
./configure --bindir=/usr/bin --sbindir=/usr/sbin --localstatedir=/var --sysconfdir=/etc
make install

Note: Again you'll need SUDO for the make command; if you've used your brains you'll have used sudo su, entered your password and not had to enter it again… just a suggestion.
Bit of permission prodding:

chown couchdb:couchdb -R /var/lib/couchdb /var/log/couchdb
update-rc.d couchdb defaults
# Service start
/etc/init.d/couchdb start

Test your install:


Yey its running
By default CouchDB will run on port 5984; you can easily change that by going to the config…

nano /etc/couchdb/default.ini
#inside the file
port = 5984
bind_address =

As you can see its also bound to your localhost (much like the default MYSQL install) so at the moment you can only access your CouchDB installer locally.
Now if you want to just expose it on the same port chance bind_address to your server ip and you can see it working on http://yourip:5984
You may need to open up your Firewall first though as follows...

iptables -A INPUT -p tcp -i eth0 --dport 5984 -m state --state NEW -j ACCEPT

Stuff direct access, give me that Lighttpd config you promised

Ok, OK! Its quick and painless and means you can leave your install bound to the localhost; it also allows you to access the site on a standard web-port rather then finding your shit stops working every-time you step behind a firewall.

So lets add this config to our Lighttpd config:

$HTTP["host"] == "" {
    proxy.server = (
        "/" => (("host" => "", "port" => 5984)) 

Restart Lighttpd
[email protected]:~# /etc/init.d/lighttpd restart

Try pinging your domain and if it goes where you've set it up to go (domain propogration is boring) then you can test it out; should display


and brings up the admin
and your JSON JS file -

Installing on Windows (doesn't deserve an entire post)

(Tested on Windows 7 64bit)
Go to and download the installer; run; as of 0.11.0 it installs the Windows Service for you as well.

Chris McKee

Chris McKee

Software Engineer, Web Front/Backend/Architecture; all-round tech obsessed geek. I hate unnecessary optimism