Saturday, October 22, 2011

Installing CouchDB in Ubuntu

I have tested the below procedure in Ubuntu 10.10 (Maverick) to install CouchDB 1.1.1 candidate release.

$ ps -ef|grep couch|awk '{print $2}'|xargs sudo kill -9
$ sudo apt-get update
$ sudo apt-get autoremove
$ sudo apt-get remove couchdb
$ sudo apt-get build-dep couchdb
$ sudo apt-get install libtool zip
$ cd
$ curl -O http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
$ tar xvzf js185-1.0.0.tar.gz 
$ cd js-1.8.5/js/src
$ ./configure
$ make
$ sudo make install
$ cd
$ curl -O http://www.erlang.org/download/otp_src_R14B04.tar.gz
$ tar xvzf otp_src_R14B04.tar.gz 
$ cd otp_src_R14B04
$ ./configure --enable-smp-support --enable-dynamic-ssl-lib --enable-kernel-poll
$ make
$ sudo make install
$ cd
$ svn co http://svn.apache.org/repos/asf/couchdb/branches/1.1.x/ couchdb1.1.x
$ cd couchdb1.1.x
$ ./bootstrap
$ prefix='/usr/local'
$ ./configure --prefix=${prefix} 
$ make
$ sudo make install
$ sudo useradd -d /var/lib/couchdb couchdb
$ sudo chown -R couchdb: ${prefix}/var/{lib,log,run}/couchdb ${prefix}/etc/couchdb
$ for dir in `whereis couchdb | sed 's/couchdb: //'`; do echo $dir | xargs sudo chown couchdb; done
$ export xulrunnerversion=`xulrunner -v 2>&1 >  /dev/null | egrep -o "([0-9]{1,2})(\.[0-9]{1,2})+"`
$ echo $xulrunnerversion
$ echo "/usr/lib/xulrunner-$xulrunnerversion" > /etc/ld.so.conf.d/xulrunner.conf
$ echo "/usr/lib/xulrunner-devel-$xulrunnerversion" >> /etc/ld.so.conf.d/xulrunner.conf
$ sudo ln -s /usr/local/etc/init.d/couchdb /etc/init.d/couchdb
$ update-rc.d couchdb defaults
$ /etc/init.d/couchdb start
$ curl -X GET http://localhost:5984
{"couchdb":"Welcome","version":"1.1.1a1187726"}

4 comments:

rizalp said...

Hi, these steps are really helping when building couchdb from source. I notice that this line:

sudo /etc/init.d/couchdb start

should be:

sudo ${prefix}/etc/init.d/couchdb start

Nestor Urquiza said...

@Rizalp

Thank you for the correction. Actually I added three lines instead, that way when restarting you make sure couchdb starts automatically and you keep the expected by the OS path (/etc/init.d/couchdb)

In addition you might want to take a second look at the way I have automated the xulrunner version configuration. Now it is ready to go in a receipt ;-)

rizalp said...

Thanks for the reply! I couldn't help but notice that your steps here is slightly different from mentioned here (Example 2 with minimal dependencies):

http://wiki.apache.org/couchdb/Installing_on_Ubuntu

This is the first time i'm installing from the source. I have tried to read both and trying to understand the concept, but kinda lost in here :

#from the link above, the last line
sudo chmod 0770 ${prefix}/var/{lib,log,run}/couchdb ${prefix}/etc/couchdb

while your steps here are different :
$ for dir in `whereis couchdb | sed 's/couchdb: //'`; do echo $dir | xargs sudo chown couchdb; done
$ export xulrunnerversion=`xulrunner -v 2>&1 > /dev/null | egrep -o "([0-9]{1,2})(\.[0-9]{1,2})+"`
$ echo $xulrunnerversion
$ echo "/usr/lib/xulrunner-$xulrunnerversion" > /etc/ld.so.conf.d/xulrunner.conf
$ echo "/usr/lib/xulrunner-devel-$xulrunnerversion" >> /etc/ld.so.conf.d/xulrunner.conf
$ sudo ln -s /usr/local/etc/init.d/couchdb /etc/init.d/couchdb
$ update-rc.d couchdb defaults
$ /etc/init.d/couchdb start
$ curl -X GET http://localhost:5984
{"couchdb":"Welcome","version":"1.1.1a1187726"}

If you don't mind, would you explain to me why? Thanks for your time

Nestor Urquiza said...

@rizalp

I have installed couchdb in several Ubuntu boxes and the steps here are the ones that lately have been working for me.

There could be other ways for sure. I tried several in the past and probably those in wiki are fine now. My recommendation would be to try them and if they work for you and they are simpler of course use them instead of mine.

In regards to what the lines are doing it is basically pivoting the result of 'whereis couchdb' command to change the ownership to the proper user. Then xulrunner.conf is populated with the current xulrunner version and finally couchdb is started as a process and schedule to start next time the box is restarted. BTW in production I really use monit to keep the daemon up and running.

Followers