Hello! This tutorial will help you set up CouchDB on a linux distribution. I’ve only tested this on Ubuntu however, so your mileage may vary until we can get some folks to try it out on Debian and whatnot!
Please note this is not a guide on how to setup your server, and there is another tutorial regarding exactly that in this Tutorial.
Step 1) Install Dependency’s
SSH into your server and follow along. We need to install some dependency’s first. You can do so by starting with:
sudo apt-get --no-install-recommends -y install \
Follow that up with:
build-essential pkg-config erlang \
And then:
libicu-dev libmozjs185-dev libcurl4-openssl-dev
Easy.
Step 2) Install CouchDB 2.0.0-1
Alright, after your dependency’s are ready, we need to go about acquiring the actual files you’re going to use to install CouchDB onto your server. Start by typing:
mkdir temp
and follow that up with
cd temp
then
wget https://raw.githubusercontent.com/afiskon/install-couchdb/master/install-couchdb.sh
then
sh install-couchdb.sh
Credit: https://github.com/afiskon/install-couchdb
Answer the questions and if prompted you choose [Single Node].
Step 3) Confirming it works.
At this point it should be installed and working, however it isn’t setup yet. If you’re accessing the server from outside, like your own personal desktop and it’s a remote server, you will not have access to the CouchDB Fauxton panel as it’s protected from the outside world at this point in the story.
You are going to want to type:
curl localhost:5984
and hope that it returns:
{"couchdb":"Welcome","version":"2.0.0","vendor":{"name":"The Apache Software Foundation"}}
If so, GREAT, if not, restart your server and try again before posting below. Thanks. Oh, and one more thing. Type:
netstat -anlp | grep 5984
and see if it returns:
tcp 0 127.0.0.1:5984 0.0.0.0:* LISTEN 3362/beam
Looking good so far if you’re at this step.
Step 4) Setting up CouchDB
At this point you’re going to need to do a few things and edit some configuration files. Normally this would be easier but we’re doing this remotely, and for the sake of this tutorial I’m not going to walk you through how to do it locally… there are actual guides on that provided by the CouchDB team.
You’re going to go into your local.ini and fix some things up. At this point, everything should be preface with a:
;
character which means that it’s commented out. You should now type:
nano /opt/couchdb/etc/local.ini
And the editor should pop up. Navigate with arrows.
We’re only interested in 2 things for this part of the tutorial. The first, navigate to the [chttpd] section and remove the semi-colon that is just before:
bind_address = 127.0.0.1
Then change the 127.0.0.1 into 0.0.0.0. At this point your local.ini [chttpd] section should look like:
[chttpd]
;port = 5984
bind_address = 0.0.0.0
; Options for the MochiWeb HTTP server.
;server_options = [{backlog, 128}, {acceptor_pool_size, 16}]
; For more socket options, consult Erlang's module 'inet' man page.
nano /opt/couchdb/etc/local.ini
;socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
Please don’t copy / paste this, it will just mess things up if you don’t know what you’re doing. That’s why I’m writing you this tutorial
You aren’t finished yet, and need to navigate to the VERY BOTTOM of the local.ini using your arrow keys. You should see a default administrator account. I recommend setting its username/password to whatever you are comfortable with and then REMOVE THE SEMI-COLON so that it is no longer commented out. The default, for example is:
;admin = mysecretpassword
Remove the ; character and change the password to something that is more secure. Remember the format is
username = password
example:
admin = correcthorsebatterystaple
Also please don’t use that password, it’s from a popular XKCD comic Password Strength
After you’re done, you’re going to want to Write Out of this local.ini file. You can do so by pressing:
CTRL + O
followed by pressing
ENTER
and then by pressing:
CTRL + X
For our last and final step you now need to restart CouchDB so that it can connect to the outside world properly. Do so by typing:
/etc/init.d/couchdb restart
You, at this point, should be able to access CouchDB by typing:
yourserverip:5984/_utils/
Step 4.5) Starting / Stopping
You can type:
/etc/init.d/couchdb stop
/etc/init.d/couchdb start
/etc/init.d/couchdb restart
to further manage CouchDB from the panel!
The End!
Congratulations. You are done and can now enjoy the luxury of having CouchDB on your Linux server! Don’t forget that after you install CouchDB and setup a real user account within the gui, it would be wise for you to go back to the local.ini and remove that username / password!
If there are any problems feel free to post them below in the comments! Someone should be able to help
Credits:
- IRC: rnewson: #couchdb @ freenode
Source for files:
Source for dependency’s: