≡ Menu

How to Install Apache CouchDB on CentOS 6 (from Source and EPEL)

We are starting a new series on CouchDB. This the first article in the CouchDB series.

CouchDB is an Apache project.

Just like the name suggest it is a database. CouchDB is a NoSQL database. NoSQL databases doesn’t have any schema, tables, etc, that you’ll typically see in a traditional databases like Oracle or MySQL. The data in CouchDB are stored as JSON document, which you can access from a web browser using HTTP.

This article explains how to install CouchDB on RHEL based systems. For example, CentOS, Red Hat, Oracle Enterprise Linux, etc.

There are two methods to install CouchDB. You can install it from EPEL repository, or install from CouchDB source code.

Method 1: Install from EPEL

First, enable EPEL repository as we explained earlier.

Verify that the couchdb is available for yum install.

# yum info couchdb
Name        : couchdb
Arch        : x86_64
Version     : 1.0.3
Release     : 2.el6
Size        : 1.7 M
Repo        : epel
Summary     : A document database server, accessible via a RESTful JSON API

Install couchdb. Depending on your system, this might install lot of dependent packages. On my system, it installed 36 packages in total.

# yum install couchdb

Modify the local.ini file and add a line for bind_address and give the ip-address the system where couchdb is installed.

# vi /etc/couchdb/local.ini
[httpd]
;port = 5984
;bind_address = 127.0.0.1
bind_address = 192.168.101.38

Start the couchdb services

# service couchdb start
Starting couchdb:                [  OK  ]

# service couchdb status
couchdb (pid  29915) is running...

Verify that the couchdb works by going to the URL: http://{your-ip-address}:5984 , it should display a web-page that has the following message.
{“couchdb”:”Welcome”,”version”:”1.0.3″}

Go to: http://{your-ip-address}:5984/_utils/ from where you can create and manage the couchdb database.

Method 2: Install from CouchDB Source Code

If you like to install it yourself from the source code, first you should satisfy all the dependencies.

Install the following standard packages from the CentOS repository.

# yum info gcc libtool xulrunner-devel libicu-devel openssl-devel

Install Erlang

Download the latest version of Erland from here. Or, you can use the wget as shown below to directly download it.

cd /usr/src
wget http://www.erlang.org/download/otp_src_R15B01.tar.gz
tar xvfz otp_src_R15B01.tar.gz

We’ll be installing couchdb and all its dependencies under /opt/couchdb directory. So, while installing erlang, give the prefix as /opt/couchdb/erlang as shown below.

cd otp_src_R15B01
./configure --prefix=/opt/couchdb/erlang --without-termcap --without-javac --enable-smp-support --disable-hipe
make
make install

Install Curl

Download the latest version of Curl from here. Or, you can use the wget as shown below to directly download it.

cd /usr/src
wget http://curl.haxx.se/download/curl-7.26.0.tar.gz
tar xvfz curl-7.25.0.tar.gz

Just like Erlang, we’ll be installing Curl also under /opt/couchdb directory. So, while installing curl, give the prefix as /opt/couchdb/curl as shown below.

cd curl-7.25.0
./configure --prefix=/opt/couchdb/curl
make
make install

SpiderMonkey JS Engine

Download the latest version of SpiderMonkey JS from here. Or, you can use the wget as shown below to directly download it.

cd /usr/src
wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
tar xvfz js185-1.0.0.tar.gz

Please note that you have to cd to “js/src” subdirectory under js-1.8.5 to do the ./configure and make as shown below to install spidermonkey js engine.

cd js-1.8.5/js/src
./configure
make
make install

You’ll see the libmozjs185.so.1.0.0 and libmozjs185-1.0.a installed under /usr/local/lib

# ls -ltr /usr/local/lib
-rwxr-xr-x. 1 root root 3671764 May 30 09:39 libmozjs185.so.1.0.0
-rwxr-xr-x. 1 root root 5523616 May 30 09:39 libmozjs185-1.0.a
lrwxrwxrwx. 1 root root      35 May 30 09:40 libmozjs185.so.1.0 -> /usr/local/lib/libmozjs185.so.1.0.0
lrwxrwxrwx. 1 root root      33 May 30 09:40 libmozjs185.so -> /usr/local/lib/libmozjs185.so.1.0

Note: If spidermonkey JS library is not installed, you’ll get the following error mesage while trying to do the ./configure mentioned in the next step.

checking for JS_NewObject in -lmozjs185... no
configure: error: Could not find the js library.

Is the Mozilla SpiderMonkey library installed?

Install CouchDB

Download the latest version of Couchdb from here. Or, you can use the wget as shown below to directly download it.

cd /usr/src
wget http://apache.mirrors.pair.com/couchdb/releases/1.2.0/apache-couchdb-1.2.0.tar.gz
tar xvfz apache-couchdb-1.2.0.tar.gz

While installing couchdb, you should set ERL, ERLC, CURL_CONFIG environment variables as shown below. These are required during the ./config of couchdb.

Just like the prereqs, we’ll be installing couchdb under /opt/couchdb directory. So, give the prefix as /opt/couchdb/couchdb as shown below.

cd apache-couchdb-1.2.0
export ERL=/opt/couchdb/erlang/bin/erl
export ERLC=/opt/couchdb/erlang/bin/erlc
export CURL_CONFIG=/opt/couchdb/curl/bin/curl-config
export LDFLAGS=-L/opt/couchdb/curl/lib
./configure --prefix=/opt/couchdb/couchdb --with-erlang=/opt/couchdb/erlang/lib/erlang/usr/include/ --enable-js-trunk
make
make install

Note: You’ll use the –enable-js-trunk only if you’ve installed the latest version (anything newer than js185-1.0.0) of the SpiderMonkey JS engine. I recommend that you use –enable-js-trunk option.

If you are not using the latest version of spidermonekey JS engine, you may want to use the flags –with-js-include and –with-js-lib and point it to the appropriate location as shown below.

./configure --prefix=/opt/couchdb/couchdb --with-erlang=/opt/couchdb/erlang/lib/erlang/usr/include/ --with-js-include=/usr/include/xulrunner-2/ --with-js-lib=/usr/lib64/xulrunner-devel-2/lib/

Note: If you’ve installed the latest version of spidermonkey js, and if you are not using –enable-js-trunk, you’ll get the following error message during “make” of couchdb:

cc1: warnings being treated as errors
In file included from couch_js/main.c:20:
couch_js/sm170.c: In function req_status:
couch_js/sm170.c:105: error: implicit declaration of function INT_FITS_IN_JSVAL
couch_js/sm170.c: In function evalcx:
couch_js/sm170.c:138: error: implicit declaration of function JS_GetStringChars
couch_js/sm170.c:138: error: assignment makes pointer from integer without a cast
couch_js/sm170.c: In function seal:
couch_js/sm170.c:220: error: implicit declaration of function JS_SealObject
couch_js/sm170.c: At top level:
couch_js/sm170.c:236: error: initialization from incompatible pointer type

Setup CouchDB Startup Services

Create a couchdb user that is required by the couchdb startup program.

# adduser couchdb

Change the ownership of the var directory, where couchdb will write logs and some other information.

# chown -R couchdb /opt/couchdb/couchdb/var/

Create a link under /etc/init.d for couchdb service

# ln -s /opt/couchdb/couchdb/etc/rc.d/couchdb /etc/init.d/couchdb

Finally start the couchdb service.

# service couchdb start
Starting database server couchdb

Verify that the couchdb works by going to the URL: http://{your-ip-address}:5984 , it should display a web-page that has the following message.
{“couchdb”:”Welcome”,”version”:”1.0.3″}

Go to: http://{your-ip-address}:5984/_utils/ from where you can create and manage the coucbdb database.

Next article in this series will explain how to create a CouchDB database and perform some basic data manipulation.

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • hdaz June 13, 2012, 6:24 am

    Hi your missing your wget command

    Or, you can use the wget as shown below to directly download it.

    cd /usr/src

    http://apache.mirrors.pair.com/couchdb/releases/1.2.0/apache-couchdb-1.2.0.tar.gz

    Cheers
    hdaz

  • Jalal Hajigholamali June 13, 2012, 7:19 am
  • Ramesh Natarajan June 14, 2012, 1:02 am

    @hdaz, @Jalal,

    Thanks for pointing out the missing ‘wget’. I’ve updated it.

  • Cody July 14, 2012, 11:43 am

    The cURL steps reference the wrong gz filename and directory folder (7.25) rather than the downloaded version 7.26:
    1) ‘tar xvfz curl-7.25.0.tar.gz’ —> should be ‘tar xvfz curl-7.26.0.tar.gz’
    2) ‘cd curl-7.25.0’ —> should be ‘cd curl-7.26.0’

  • Dave Cottlehuber January 28, 2013, 2:26 am

    Thanks for the writeup!

    Please *don’t* enable the -use-js-trunk option. It does not do what you think it does, and if somebody is using a newer spidermonkey version (perhaps from another installed package) the resulting couch will not work.

  • Robert January 28, 2015, 11:14 am

    On the Install CouchDB step, I was having issues with Erlang “not” being installed. ERL exported correctly, but when I ran the configure, it wasn’t found. I added these lines:

    export ERL=/opt/couchdb/erlang/bin/erl
    export ERLC=/opt/couchdb/erlang/bin/erlc
    export CURL_CONFIG=/opt/couchdb/curl/bin/curl-config
    export LDFLAGS=-L/opt/couchdb/curl/lib

    to the first part of the configure script instead of to just bash, and that solved my problem. Does anyone know what might have been up with that?
    By the way, I checked PATH inside the configure, and it was different from PATH on bash, which is why I decided to export it inside the script (It took a lot of head scratching though)

  • Cepxio March 17, 2015, 1:35 pm

    Hi, I have this error when run make

    make[5]: se ingresa al directorio `/usr/local/src/apache-couchdb-1.6.1/src/couchdb/priv’
    gcc -DHAVE_CONFIG_H -I. -I../../.. -I../../../src/snappy/google-snappy -D_XOPEN_SOURCE -I/opt/local/include -I/opt/local/include/js -I/usr/local/include -I/usr/local/include/js -I/usr/include -I/usr/include/js -g -Wall -Werror -D_BSD_SOURCE -I/opt/couchdb/curl/include -DXP_UNIX -DXP_UNIX -DJS_THREADSAFE -I/usr/include/xulrunner-17.0.10 -I/usr/include/nspr4 -O2 -g -O2 -MT couch_js/couchjs-main.o -MD -MP -MF couch_js/.deps/couchjs-main.Tpo -c -o couch_js/couchjs-main.o `test -f ‘couch_js/main.c’ || echo ‘./’`couch_js/main.c
    In file included from couch_js/main.c:16:
    couch_js/sm185.c: En la función ‘main’:
    couch_js/sm185.c:328: error: ‘JSScript’ no se declaró aquí (primer uso en esta función)
    couch_js/sm185.c:328: error: (Cada identificador no declarado solamente se reporta una vez
    couch_js/sm185.c:328: error: para cada funcion en la que aparece.)
    couch_js/sm185.c:328: error: ‘script’ no se declaró aquí (primer uso en esta función)
    make[5]: *** [couch_js/couchjs-main.o] Error 1
    make[5]: se sale del directorio `/usr/local/src/apache-couchdb-1.6.1/src/couchdb/priv’
    make[4]: *** [all] Error 2
    make[4]: se sale del directorio `/usr/local/src/apache-couchdb-1.6.1/src/couchdb/priv’
    make[3]: *** [all-recursive] Error 1
    make[3]: se sale del directorio `/usr/local/src/apache-couchdb-1.6.1/src/couchdb’
    make[2]: *** [all-recursive] Error 1
    make[2]: se sale del directorio `/usr/local/src/apache-couchdb-1.6.1/src’
    make[1]: *** [all-recursive] Error 1
    make[1]: se sale del directorio `/usr/local/src/apache-couchdb-1.6.1′
    make: *** [all] Error 2
    [root@CouchDB apache-couchdb-1.6.1]#

    The ./configure step finished well, so I don’t know what is the problem.

  • Rob October 17, 2015, 11:23 am

    I got as far as installing spidermonkey following these instructions (in a clean vagrant VM running Centos 6.6), but came across this error while configuring spidermonkey:

    gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory
    configre: failed program was:

    #line 2985 “configure”
    #include “confdefs.h”

    int main(){return(0);}
    configure: error: installation or configuration problem: C++ compiler cannot create executables.

    I initally tried using the latest version of spidermonkey, but had the same problem using the version listed here. Has anyone else run into this problem?