Installing geocouch

Right, having installed couchdb everything went wrong when I installed geocouch.  But I have that fixed now, so I thought I would again make a note of what worked.

OS Ubuntu 11.10

couchdb 1.1.1

geocouch 1.1.x

First, I cloned geocouch from github:

git clone -b couchdb1.1.x  https://github.com/couchbase/geocouch.git

Note: select the correct branch for the version of couchdb running.  I think the default is master which is configured to work with couchbase.  So, selecting the branch (-b) is important.

Now, I originally cloned geocouch into the ~/Downloads directory.  Big mistake, since it subsequently became clear that Erlang couldn’t use the directory even when it was on its path.  So, I moved geocouch to /usr/local/src:

mv ~/Downloads/geocouch /usr/local/src/

Now comes the tricky bit.  In the ReadMe they use a <vanilla-couch> variable to designate the path to the couchdb source.  But, they also use it for the path to the /default.d directory of the installed couchdb, a different place – now that is confusing.

So, first set a local environment variable COUCH_SRC in the terminal.  The ‘make’ file uses this variable.  You don’t need to make this variable permanent, since it is only used when making geocouch.

export COUCH_SRC=/usr/local/src/apache-couchdb-1.1.1/src/couchdb

Go into the geocouch directory

cd /usr/local/src/geocouch

And run the make command

make

This creates a new directory called /build with lots of .beam files.

Now, Erlang needs to have these .beam files on its path.  Therefore, set the following environment variable:

ERL_FLAGS="-pa /usr/local/src/geocouch/build"

I edited the /etc/environment file to persist the ERL_FLAGS environment variable.  I think you need to login again to make the change.

Finally, geocouch has a geocouch.ini file here: … /geocouch/etc/couchdb/local.d/  Copy this into the /local.d directory of the installed couchdb (not the source).  I happen to have the couchdb installed at /opt/couchdb/.

sudo cp /usr/local/src/geocouch/etc/couchdb/local.d/geocouch.ini /opt/couchdb/etc/couchdb/local.d/

That’s it.

Geocouch comes with some tests to check that the install has worked.  First copy the test scripts into your installed couchdb:

cp /usr/local/src/geocouch/share/www/script/test/* /opt/couchdb/share/couchdb/www/script/test/

Then edit the couch_tests.js file to include these new tests.

sudo gedit /opt/couchdb/share/couchdb/www/script/couch_tests.js

Paste in:

loadTest("spatial.js"); 
loadTest("list_spatial.js"); 
loadTest("etags_spatial.js"); 
loadTest("multiple_spatial_rows.js"); 
loadTest("spatial_compaction.js"); 
loadTest("spatial_design_docs.js"); 
loadTest("spatial_bugfixes.js");

Start couchdb

sudo /etc/init.d/couchdb start

Then check

curl localhost:5984

Leave a comment