Sad enough, seems that there is no version of CouchDB 1.2 in Ubuntu Software Sources -you will find 1.0.1 but it is pretty old- so you have to download and compile it!
Installing Ubuntu Desktop 12.04 LTS
The very first thing is going to Ubuntu site and download the ISO image (I have chosen Desktop -easier administration- and 64 bits edition).
Since I run it in a virtual machine (with VmWare Fussion) and after a couple of unsuccessful (easy) installations I’ve decide to go with manual installation.
My (non-default) Settings are:
- Processor & RAM: 1 CPU, 3072 MB.
- Hard Disks: SCSI Disk, 40 GB (Split in 2 GB files).
- Network: NAT (Generated MAC address – click on Advanced Options and then Generate).
Doing it manually went pefectly well other than the resolution originally set during the installation (5120 x 3200) that I switched to 1024×768 by clicking on an icon on the top right corner -a gear- and then choosing System Setting… > Displays).
During the installation I have chosen NOT to download upgrades / updates so I did it just after the reboot. The easiest way is open a terminal and run:
$ sudo apt-get update $ sudo apt-get dist-upgrade $ sudo reboot
It downloads from your source repository the description of the updates and then the second command upgrade packages installed and outdated.
NOTE: I reboot the system since the kernel was updated too.
Installing CouchDB 1.2
- Start installing some packages that are going to be needed:
$ sudo apt-get install g++ $ sudo apt-get install erlang-base erlang-dev erlang-eunit erlang-nox $ sudo apt-get install libmozjs185-dev libicu-dev libcurl4-gnutls-dev libtool
- Then go to CouchDB site and choose to download sources.
- In a terminal, go to the folder where you have downloaded the file and run:
$ ./configure $ make $ sudo make install
- Start couchdb
$ sudo couchdb Apache CouchDB 1.2.0 (LogLevel=info) is starting. Apache CouchDB has started. Time to relax. [info] [<0.32.0>] Apache CouchDB has started on http://127.0.0.1:5984/
- Check that is actually running using curl (install it if needed):
$ sudo apt-get install curl $ curl -X GET http://localhost:5984 [info] [<0.361.0>] 127.0.0.1 - - GET / 200 {"couchdb":"Welcome","version":"1.2.0"} $
And, hopefully, that’s it!
Setting CouchDB as service
Maybe you don’t want to start CouchDB manually each time you reboot your machine.
In that case some few things to do:
- Add couchdb user and group.
$ sudo adduser --disabled-login --disabled-password --no-create-home couchdb Adding user `couchdb' ... Adding new group `couchdb' (1001) ... Adding new user `couchdb' (1001) with group `couchdb' ... Not creating home directory `/home/couchdb'. Changing the user information for couchdb Enter the new value, or press ENTER for the default Full Name []: CouchDB Admin Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] Y $
- Check/set right owner for files and folders (alternatively, you might have it installed in /var instead of /usr/local/var.
$ sudo chown -R couchdb:couchdb /usr/local/var/log/couchdb $ sudo chown -R couchdb:couchdb /usr/local/var/lib/couchdb $ sudo chown -R couchdb:couchdb /usr/local/var/run/couchdb $
- Link couchdb service script to /etc/init.d.
$ sudo ln -s /usr/local/etc/init.d/couchdb /etc/init.d $
- Configure service to start when you enter / change levels:
$ sudo update-rc.d couchdb defaults Adding system startup for /etc/init.d/couchdb ... /etc/rc0.d/K20couchdb -> ../init.d/couchdb /etc/rc1.d/K20couchdb -> ../init.d/couchdb /etc/rc6.d/K20couchdb -> ../init.d/couchdb /etc/rc2.d/S20couchdb -> ../init.d/couchdb /etc/rc3.d/S20couchdb -> ../init.d/couchdb /etc/rc4.d/S20couchdb -> ../init.d/couchdb /etc/rc5.d/S20couchdb -> ../init.d/couchdb $
Next time that you reboot your machine you should be able to access CouchDB with no additional actions.
Possible errors / problems
This is a list of errors that I’ve seen not following these steps:
- When erlang is not installed you get:
checking for erl... no configure: error: Could not find the `erl' executable. Is Erlang installed?
- Original documentation says to install libmozjs-dev but it is not in Ubuntu Software Sources: Install libmozjs185-dev.
- When g++ is not installed, configure phase fails complaining about SpiderMonkey not installed!!! Please, install g++ and try again. This is the error that I got:
checking for JS185... yes checking for JS185... yes checking for JS185... yes checking for jsapi.h... no checking js/jsapi usability... no checking js/jsapi.h presence... no checking for js/jsapi.h... no configure: error: Could not find the jsapi header Are the Mozilla SpiderMonkey headers installed? $ ls /usr/include/js/jsapi.h -rw-r--r-- 1 root root 136254 Mar 31 2011 /usr/include/js/jsapi.h $
- When erlang-eunit is not installed you get errors at compile time (even that configure finish correctly). Install erlang-eunit to fix it! This is the error that I got:
$ make make all-recursive make[1]: Entering directory `/home/onabai/Downloads/apache-couchdb-1.2.0' Making all in bin make[2]: Entering directory `/home/onabai/Downloads/apache-couchdb-1.2.0/bin' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/home/onabai/Downloads/apache-couchdb-1.2.0/bin' ... Making all in mochiweb make[3]: Entering directory `/home/onabai/Downloads/apache-couchdb-1.2.0/src/mochiweb' /usr/bin/erlc mochifmt.erl ./mochifmt.erl:none: error in parse transform 'eunit_autoexport': {undef, [{eunit_autoexport, parse_transform, [[{attribute,1,file, {"./mochifmt.erl",1}}, {attribute,7,module, mochifmt}, {attribute,8,author, 'bob@mochimedia.com'}, {attribute,9,export, [{format,2}, {format_field,2}, {convert_field,2}, {get_value,2}, {get_field,2}]}, {attribute,10,export, [{tokenize,1}, {format,3}, {get_field,3}, {format_field,3}]}, {attribute,11,export, [{bformat,2},{bformat,3}]}, ... {compile, '-foldl_transform/2-anonymous-2-', 2}, {compile,foldl_transform,2}, {compile, '-internal_comp/4-anonymous-1-', 2}, {compile,fold_comp,3}, {compile,internal_comp,4}, {compile,internal,3}]} make[3]: *** [mochifmt.beam] Error 1 make[3]: Leaving directory `/home/onabai/Downloads/apache-couchdb-1.2.0/src/mochiweb' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/onabai/Downloads/apache-couchdb-1.2.0/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/onabai/Downloads/apache-couchdb-1.2.0' make: *** [all] Error 2 $
- If you did not install erlang-nox package you get an error when try to run CouchDB. Install it and re-run CouchDB. The error is something like this:
$ sudo couchdb {"init terminating in do_boot",{{badmatch,{error,{"no such file or directory","inets.app"}}},[{couch,start,0},{init,start_it,1},{init,start_em,1}]}} Crash dump was written to: erl_crash.dump init terminating in do_boot () $
for clarity there should be a instruction to execute “./configure” before “make && sudo make install” it trips some people up 🙂
Thank you for the comment. Updated!
Thanks for this! Saved me quite a few minutes working out all the dependencies!
A small suggestion, rather than the traditional init.d scripts, I personally prefer to use upstart. Its just a bit easier to set up. Here is a gist of my config, ready to drop into the /etc/init/ directory:
couchdb.conf
hosted with ❤ by GitHub
Cheers, sam
Very nice article explaining the steps to be followed for installing CouchDB in Uuntu
The only other issue I had was when I “Fixed the admin party”, logs said i was getting eaccess error.
Logs said.
Couldn’t write config file /usr/local/etc/couchdb/local.ini: permission denied
Basically i think
sudo chown -R couchdb:couchdb /usr/local/etc/couchdb/
is needed to allow couchdb user to update the file(which is owned by root)
Yes, you might need to change permissions if you start couchdb as couchdb user.
The steps that I listed, actually start couchdb as “root” since they are started on init as a service, so they don’t need changing permissions.
I encountered the same problem, and this fixed it. It can’t hurt, so I would put it in Possible Errors/Problems
I have used this tutorial multiple times because it is so clear! I would like to note one tiny error to avoid confusion:
NOTE: I reboot the system since the kernel was update too.
should read
NOTE: I reboot the system since the kernel was updated too.
Spelling corrected, Thanks!
Thanks for saving me hours of work. Superb
Thank you for the nice tutorial. When I initially started couchdb by running /usr/local/bin/couchdb as ‘root’, several files were created under /usr/local/var/[lib|log|run]/couchdb owned by ‘root’.
Later, when attempting couchdb as a service under user ‘couchdb’, the files owned by root were interfering and causing the process to fail silently.
Editing
/usr/local/etc/default/couchdb
and changing
COUCHDB_STDOUT_FILE=/dev/null
COUCHDB_STDERR_FILE=/dev/null
tou a suitable location writeable by all such as:
COUCHDB_STDOUT_FILE=/tmp/couch.out
COUCHDB_STDERR_FILE=/tmp/couch.err
helped pinpoint the problem.
In the post I already say “Check/set right owner for files and folders (alternatively, you might have it installed in /var instead of /usr/local/var.” and I suggested to change the owner and group.
Yes, it’s also possible to change where to save those files but since you are not compromising the security changing permissions, I’ve opted for it.
Anyhow, that should work also!
Regards
Thanks for the guide, it helped me,install the most recent version (1.4) in ubuntu 12.04
I suggest you replace the command “sudo couchdb” with “sudo couchdb -b”, as shown also on
http://guide.couchdb.org/draft/source.html#manually.
This way users will be able to later stop the background process with “sudo couchdb -d”
In my first attempt to install, I started couchdb with “sudo couchdb” but wanted to use the same terminal to continue with the installation. Therefore I suspended it with CTRL+Z and put it to run in background with “fg 1”. Unfortunately, after verifying with curl that couchdb was running, I could only stop it by killing all couchdb related processes.