How To Install CouchDB On Slackware

Published: {ts '2011-06-11 00:00:00'}
Author: Steven Neiland
Site Url: http://www.neiland.net/article/how-to-install-couchdb-on-slackware/

Ever since I came back from cfobjective() I have been wanting to get started with CouchDB. For those of you who dont know, Couch DB is a document database server which you access via a REST JSON API.

So before I do anything with CouchDB I first have to install it. This blog entry will cover everything I needed to do to get it running on Slackware Linux.

Step 1: Install the Dependencies

Before we install CouchDB we must first ensure that the following projects are installed. Fortunately they exist as SlackBuilds. The rest of the dependencies for CouchDB come with Slackware and are normally installed by default. For a full list of couchDB's dependencies checkout the CouchDB Guide.

Install JS

First lets install the JS package which is "SpiderMonkey, Mozilla's JavaScript Engine". Note the versions numbers may differ as I am installing for Slackware 13.

cd /[your downloads folder] wget http://slackbuilds.org/slackbuilds/13.0/network/js.tar.gz tar xzf js.tar.gz cd js wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz ./js.SlackBuild cd /tmp installpkg js-1.8.0_rc1-i486-1_SBo.tgz

Install icu4c

Next we install the icu4c package which consists of a set of international unicode lobraries.

cd /[your downloads folder] wget http://slackbuilds.org/slackbuilds/13.0/libraries/icu4c.tar.gz tar xzf icu4c.tar.gz cd icu4c wget http://download.icu-project.org/files/icu4c/4.2.1/icu4c-4_2_1-src.tgz ./icu4c.SlackBuild cd /tmp installpkg icu4c-4.2.1-i486-1_SBo.tgz

Step 1: Install the Dependencies (continued)

Install Erlang

Finally we install Erlang which is a general-purpose concurrent programming language and runtime system.

cd /[your downloads folder] wget http://slackbuilds.org/slackbuilds/13.0/development/erlang-otp.tar.gz tar xzf erlang-otp.tar.gz cd erlang-otp wget http://www.erlang.org/download/otp_src_R13B03.tar.gz wget http://www.erlang.org/download/otp_doc_man_R13B03.tar.gz ./erlang-otp.SlackBuild cd /tmp installpkg erlang-otp-13B03-i486-1_SBo.tgz

Step 2: Create User and Group

As a security precaution we create a dedicated couchdb user and group so that if couchDB is compromised by an attacker, the attacker will not get access to a superuser account.

groupadd couchdb useradd -g couchdb -d /usr/local/var/lib/couchdb -s /bin/sh couchdb

Step 3: Download and Configure the CouchDB Source

Now select your download source from CouchDB Website and download. Once downloaded unpack it and place in the "/usr/local/" directory.

cd /[your downloads folder] wget http://apache.opensourceresources.org//couchdb/1.0.2/apache-couchdb-1.0.2.tar.gz tar xzf apache-couchdb-1.0.2.tar.gz mv apache-couchdb-1.0.2 /usr/local/

Step 4: Configure and Install

We now need to configure the source and make it. Fortunately we dont need to add any configuration options. Simply cd into the couchdb directory and run the configure, make and make install commands.

cd /usr/local/apache-couchdb-1.0.2 ./configure make make install

Step 5: Change Ownership And Set Permissions of the CouchDB Directories

We now set the ownership of the created couchdb directories and set the execution permission so that the couchdb user can run the couchdb application.

chown -R couchdb:couchdb /usr/local/etc/couchdb chown -R couchdb:couchdb /usr/local/var/lib/couchdb chown -R couchdb:couchdb /usr/local/var/log/couchdb chown -R couchdb:couchdb /usr/local/var/run/couchdb 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

Step 6: Run Manually To Test

If we have done everything correctly we should now be able to start CouchDB manually using the following command. We should get a message that "Apache CouchDB has started, time to Relax".

sudo -i -u couchdb couchdb -b

With CouchDB running point your web browser to http://127.0.0.1:5984/_utils. You should be presented with the CouchDB utility screen.

Step 7: Configure CouchDB to Start Automatically

Since we dont want to have to manually start CouchDB every time we restart the machine our next task is to create a startup script. In slackware we create this script at "/etc/rc.d/rc.couchdb". Here is my startup code.

Create Startup Script

Create "/etc/rc.d/rc.couchdb" and paste in the following code.

# Start/stop/restart the CouchDB server. case "$1" in 'start') sudo /usr/local/etc/rc.d/couchdb start ;; 'stop') sudo /usr/local/etc/rc.d/couchdb stop ;; 'restart') sudo /usr/local/etc/rc.d/couchdb stop sudo /usr/local/etc/rc.d/couchdb start ;; *) echo "Usage: $0 {start|stop|restart}" ;; esac

In order to run we must set rc.couchdb as executable.

chmod 755 /etc/rc.d/rc.couchdb

Start CouchDB from the Startup Script

Open the "/etc/rc.d/rc.M" file and paste in the following.

#start couchdb if [ -x /etc/rc.d/rc.couchdb ]; then . /etc/rc.d/rc.couchdb start fi

Stop CouchDB from the Shutdown Script

Open the "/etc/rc.d/rc.6" file and paste in the following.

#stop couchdb if [ -x /etc/rc.d/rc.couchdb ]; then . /etc/rc.d/rc.couchdb stop fi