How to setup CouchDB 2.0.0-1 on Ubuntu, Debian, and more!

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 :slight_smile:

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 :slight_smile:

Credits:

Source for files:

Source for dependency’s:

4 Likes

Could really use something like this for Windows, couchdb just doesn’t want to connect for me

Couldn’t get it working for me either, so I had to move to Ubuntu :slight_smile: Maybe someone could chime in with their own Windows based tutorial sometime. My CouchDB service kept crashing~

Actually just found a fix! https://github.com/apache/couchdb/issues/508

I did everything right, but when I visit the site, I just get an error.

Perhaps they changed the repo names. I’ll contact the CouchDB folks to see if there’s a solution.

Awesome post ~ Thanks for all the useful info! you made setting up CouchDB on a VPS a breeze!

In regards to creating a “real user account” for anyone who may be a bit confused…
I simply created a “_user” database


i then opened the database and added the following:

{
    "_id": "org.couchdb.user:YourUsername",
    "name": "YourUsername",
    "type": "user",
    "roles": [],
    "password": "YourPassword"
}

Not 1000% sure that was the right way to go about things, but it appears to work well!

Thanks again!

If you did it and it works there isn’t anything wrong :slight_smile:

It does not work for me, could you help?

what error are you getting?.. if its a 404 then you likely did not bind the ip correctly… you may want to redo the steps provided by supaCURE as every step is correct and vital as the next!

Error 404, I tried it many times, I followed all the steps correctly.

what do you get under [chttpd] when you type “nano /opt/couchdb/etc/local.ini”
also, did you check if couch db is even running?

[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.
;socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]

1 Like

remove the ; symbol before bind_address!!!

Try that please (forgot to tag you in previous post)

OMG! Awesome, thank you very much, bro!

1 Like

Never a problemo!


Glad to see you got it running! :wink:

1 Like

Do all these links still work for everyone? I was informed they’d be taken down eventually and I’m not sure exactly when so keep me posted.

https://atypical.net/couchdb-pkg/jessie /” This link is down.