So, in the last post I gave an introduction to the concepts behind CouchDB and other document store systems. For this post, I had intended to overview compiling on both Mac OS X and Ubuntu 9.10 Beta. However, on the Mac front, it turned out there was already project with a nicely cooked binary that would be significantly easier to install, and, let’s face it, just more Steve Jobs than compiling from source. If you are running Mac OS X Leopard (10.5), you can download the CouchDBX binary here.
The application should be dropped into your /Applications folder, a fairly standard procedure. Once you run it, you’ll be greeted with the CouchDB web interface, which is actually embedded into the CouchDBX program. Not necessarily the way you’d want to run it in production, but you probably aren’t serving your apps from a standard Leopard install anyway. It should look like the following:

CouchDBX Mac OS X Application
So let’s talk Ubuntu. I am certain you are more likely to serve CouchDB production apps from a Linux server, instead of a graphical interface, so we’ll go through compiling a fresh install on Ubuntu Server 9.10 Beta. (I’ll update this page once it is released if there are any significant alterations.)
Obviously, this is Ubuntu, so you could install from the repositories if you wished. However, the last few iterations of Ubuntu 9.10 have had some issues with CouchDB — if you are going to install from the repos, you must “tweak” a few things afterwards. Keep in mind — these are steps I am taking to try and make it work, it is probably not the “recommended” method by the Ubuntu “Masters of the Universe”, and so hopefully it will be patched soon.
sudo apt-get update sudo apt-get install couchdb # The last command will end up failing. sudo mkdir /var/log/couchdb sudo apt-get install xulrunner # You will get a new, different couchdb failure sudo ln -s /usr/bin/xulrunner /usr/bin/xulrunner-1.9.1
…and even after all that, couchdb doesn’t seem to start up due to a permissions / port issue that I’m still working out. So, that’s the “easy” path if you want pre-built binaries.
Will most likely be working by / shortly after release, I’m sure.
So, to compile. My commands will be run in a fresh install as a virtual image in VirtualBox. This process should work for any version of Ubuntu 9.10 – (Desktop or Server, 32-bit or 64-bit), but just so you know this is on the Server / 64-bit image.
By the way, one of the things I love about Ubuntu 9.10 — this screen on the installation process:
Anyway, once you have logged in via SSH or whatever, run the following commands, tweaking as necessary: (A huge thank you to till’s blog post, from which these commands were either tweaked or stolen, you pick.)
- sudo apt-get update
- sudo apt-get install build-essential autoconf automake checkinstall libtool help2man
- (That gets all of the build tools.)
- sudo apt-get install erlang libicu-dev libmozjs-dev libcurl4-openssl-dev
- (That gets all the dependencies.)
- mkdir Source
- cd Source
- wget http://mirror.cloudera.com/apache/couchdb/0.9.1/apache-couchdb-0.9.1.tar.gz
- (Or another mirror, you can go to couchdb.apache.org to find a download link.)
- tar xvzf apache-couchdb-0.9.1.tar.gz
- cd apache-couchdb-0.9.1/
- ./configure
- make
- sudo checkinstall -D –pkgname=couchdb –pkgversion=0.9.1 –maintainer=email@address.org –pkglicense=Apache
- sudo ln -s /usr/local/etc/init.d/couchdb /etc/init.d/couchdb
- sudo update-rc.d couchdb defaults
- sudo ln -s /usr/local/etc/logrotate.d/couchdb /etc/logrotate.d/couchdb
- sudo vim /usr/local/etc/default/couchdb
- (Change COUCHDB_USER=couchdb to COUCHDB_USER=root)
- OPTIONAL:
- sudo vim /usr/local/etc/couchdb/local.ini
- (“Uncomment” the ;address = 127.0.0.1 line and change it to address = 0.0.0.0 to enable access from any ip / hostname. You can change the port too, if you’d like.)
…and you should be done! The server should start up by itself whenever the system starts, or you would normally use the sudo /etc/init.d/couchdb start (or stop, or restart) commands, but for this first time you really should just type sudo couchdb , because the following message just sums up the entire application:
- Apache CouchDB 0.9.1 (LogLevel=info) is starting.
- Apache CouchDB has started. Time to relax.
In a web browser, navigate to http://HOST_IP:5984/ (HOST_IP will be 127.0.0.1 if you are on the same system, otherwise you’ll need to determine your internal network). You should see something like the following:
- {“couchdb”:”Welcome”,”version”:”0.9.1″}
Note that this message is in JSON, and that it is working.
Next time, we’ll dig into the meat of CouchDB and talk about how to start storing and retrieving your documents!
