How to install CouchDB 1.6.1 on Debian 8.2 (jessie)

November 18, 2015

First, I must give credit where it is due. These instructions are based on Matteo Mattei’s earlier article Install CouchDB 1.6.x on Debian 7 (Wheezy), but with some important changes.

The commands below assume you have sudo properly configured on your system, and that you are running as a standard user. If you’re doing everything as root: 1) Don’t. That’s a bad idea! 2) Remove ‘sudo’ as appropriate.

Installing dependencies

  1. Configure sources.list

    You need to add the sources for the Erlang dependencies to /etc/apt/sources.list. You can do this with a text editor, or with the following command:

sudo echo "deb http://packages.erlang-solutions.com/debian jessie contrib" > /etc/apt/sources.list.d/erlang-solutions.list
  1. Install the Erlang repository key
wget -qO - http://packages.erlang-solutions.com/debian/erlang_solutions.asc | sudo apt-key add -
  1. Update the package listing, and install standard build dependencies
sudo aptitude update
sudo aptitude install build-essential curl libmozjs185-1.0 libmozjs185-dev libcurl4-openssl-dev libicu-dev wget curl
  1. Install the proper versions of the necessary Erlang packages

    This is the trickiest part. If you install the default versions, you’ll get a version of Erlang which is incompatible with CouchDB (thanks to Erlang being newer than couchDB). So you must install an older version explicitly. This is a messy process if done manually. I’ve done the hard work for you, if you’re willing to simply copy-and-paste the following command:

    sudo aptitude install erlang-dev=1:17.5.3 erlang-base=1:17.5.3 erlang-crypto=1:17.5.3 \
                          erlang-nox=1:17.5.3 erlang-inviso=1:17.5.3 erlang-runtime-tools=1:17.5.3 \
                          erlang-inets=1:17.5.3 erlang-edoc=1:17.5.3 erlang-syntax-tools=1:17.5.3 \
                          erlang-xmerl=1:17.5.3 erlang-corba=1:17.5.3 erlang-mnesia=1:17.5.3 \
                          erlang-os-mon=1:17.5.3 erlang-snmp=1:17.5.3 erlang-ssl=1:17.5.3 \
                          erlang-public-key=1:17.5.3 erlang-asn1=1:17.5.3 erlang-ssh=1:17.5.3 \
                          erlang-erl-docgen=1:17.5.3 erlang-percept=1:17.5.3 erlang-diameter=1:17.5.3 \
                          erlang-webtool=1:17.5.3 erlang-eldap=1:17.5.3 erlang-tools=1:17.5.3 \
                          erlang-eunit=1:17.5.3 erlang-ic=1:17.5.3 erlang-odbc=1:17.5.3 \
                          erlang-parsetools=1:17.5.3
    

    Then put the packages on hold, or you’ll end up inadvertently upgrading them, and breaking CouchDB.

    sudo aptitude hold erlang-dev erlang-base erlang-crypto erlang-nox erlang-inviso erlang-runtime-tools \
                          erlang-inets erlang-edoc erlang-syntax-tools erlang-xmerl erlang-corba \
                          erlang-mnesia erlang-os-mon erlang-snmp erlang-ssl erlang-public-key \
                          erlang-asn1 erlang-ssh erlang-erl-docgen erlang-percept erlang-diameter \
                          erlang-webtool erlang-eldap erlang-tools erlang-eunit erlang-ic erlang-odbc \
                          erlang-parsetools
    

Set up the CouchDB environment

You can simply copy and paste these commands into a terminal window:

sudo useradd -d /var/lib/couchdb couchdb
sudo mkdir -p /usr/local/{lib,etc}/couchdb /usr/local/var/{lib,log,run}/couchdb /var/lib/couchdb
sudo chown -R couchdb:couchdb /usr/local/{lib,etc}/couchdb /usr/local/var/{lib,log,run}/couchdb
sudo chmod -R g+rw /usr/local/{lib,etc}/couchdb /usr/local/var/{lib,log,run}/couchdb

Download, compile and install CouchDB

Again, you can simply copy and paste these commands. Make sure you do this from a location where a directory can be created and source files unpacked and built. ~/src might be a handy place

wget http://apache.panu.it/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz
tar xzf apache-couchdb-1.6.1.tar.gz
cd apache-couchdb-1.6.1
./configure --prefix=/usr/local --with-js-lib=/usr/lib --with-js-include=/usr/include/js --enable-init
make && sudo make install

Finish setting up the environment

Copy and paste these commands:

sudo chown couchdb:couchdb /usr/local/etc/couchdb/local.ini
sudo ln -s /usr/local/etc/init.d/couchdb /etc/init.d/couchdb
sudo ln -s /usr/local/etc/couchdb /etc
sudo update-rc.d couchdb defaults
sudo /etc/init.d/couchdb start

Verify

To verify your installation, you can visit http://localhost:5984/ from your browser (if you have installed on your local machine), or from the console using curl:

curl http://127.0.0.1:5984/

And you should get a response something like this:

{
    "couchdb": "Welcome",
    "uuid": "a176f89954c3ddba7aa592d712c25140",
    "version": "1.6.1",
    "vendor": {
        "name": "The Apache Software Foundation",
        "version": "1.6.1"
    }
}

Create an admin account

After a fresh install of CouchDB, anyone who can connect to the server can create a database, or do other destructive things. This is called the Admin party, and you need to close this hole by creating an account before opening your server to the world.

You can create an admin account from the command line as described here, or you can browse to the Futon interface at http://127.0.0.1:5984/_utils to do it with a web browser.

Open access to the world

Once you’ve created an admin account, you may wish to open your CouchDB instance to the world. Do this by editing the config file /etc/couchdb/local.ini, and adding the following line to the [httpd] section:

bind_address = 0.0.0.0

Then restart the service:

/etc/init.d/couchdb restart

Finished

At this point, you can begin using CouchDB, or continue with additional configurations.


comments powered by Disqus