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

by Ramesh Natarajan on June 13, 2012

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.


Linux Sysadmin Course Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the Linux Sysadmin Course Now!

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

{ 5 comments… read them below or add one }

1 hdaz June 13, 2012 at 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

2 Jalal Hajigholamali June 13, 2012 at 7:19 am
3 Ramesh Natarajan June 14, 2012 at 1:02 am

@hdaz, @Jalal,

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

4 Cody July 14, 2012 at 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′

5 Dave Cottlehuber January 28, 2013 at 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.

Leave a Comment

Previous post:

Next post: