Host CouchDB 2.0

January 18, 2017 5.7k views
NoSQL

Hello,

I'm very new to DigitalOcean and getting a server setup. Is this tutorial still current?

https://www.digitalocean.com/community/tutorials/how-to-install-couchdb-and-futon-on-ubuntu-14-04

I know CouchDB is at 2.0 now.

I'm also wondering how do you securely expose CouchDB to PouchDB from a mobile client such as Ionic 2.

I currently have a Cloudant setup with NodeJS and I'm trying to find an alternative due to API call costs.

Thanks,

dhndeveloper

1 comment
  • I've used these Install Instructions for CouchDB 2.1.1 on a DigitalOcean Droplet running Ubuntu 16.04

    ssh root@Droplet-IP-ADDRESS
    root@ubuntu-droplet:~# cd ../home
    root@ubuntu-droplet:/home# mkdir temp

    root@ubuntu-droplet:/home# cd temp

    Copy and paste the "install-couchdb.sh" script included below to a file in the "/home/temp" directory and name it "install-couchdb.sh"

    root@ubuntu-droplet:/home/temp# nano install-couchdb.sh

    Then change the permissions and run the script:

    root@ubuntu-droplet:/home/temp# chmod 777 install-couchdb.sh

    Run the script to install CouchDB

    root@ubuntu-droplet:/home/temp# ./install-couchdb.sh

    After install:

    root@ubuntu-droplet:/home/couchdb# curl http://localhost:5984

    Output should be something like: {"couchdb":"Welcome","version":"2.1.1","features":["scheduler"],"vendor":{"name":"The Apache Software Foundation"}} Edit local ini file to bind ip address:

    root@ubuntu-droplet:/home/couchdb# nano etc/local.ini

    restart the server sudo reboot

    root@ubuntu-droplet:~# curl http://IP ADDRESS:5984

    Output should be something like: {"couchdb":"Welcome","version":"2.1.1","features":["scheduler"],"vendor":{"name":"The Apache Software Foundation"}} The script below is an updated version of the one found here: https://github.com/afiskon/install-couchdb/blob/master/install-couchdb.sh ####### install-couchdb.sh Script !/bin/sh

    set -e

    sudo apt-get update || true
    sudo apt-get --no-install-recommends -y install \
    build-essential pkg-config runit erlang \
    libicu-dev libmozjs185-dev libcurl4-openssl-dev

    wget http://apache-mirror.rbc.ru/pub/apache/couchdb/source/2.1.1/apache-couchdb-2.1.1.tar.gz

    tar -xvzf apache-couchdb-2.1.1.tar.gz
    cd apache-couchdb-2.1.1/
    ./configure && make release

    sudo adduser --system \
    --no-create-home \
    --shell /bin/bash \
    --group --gecos \
    "CouchDB Administrator" couchdb

    sudo cp -R rel/couchdb /home/couchdb
    sudo chown -R couchdb:couchdb /home/couchdb
    sudo find /home/couchdb -type d -exec chmod 0770 {} \;
    sudo sh -c 'chmod 0644 /home/couchdb/etc/*'

    sudo mkdir /var/log/couchdb
    sudo chown couchdb:couchdb /var/log/couchdb

    sudo mkdir /etc/sv/couchdb
    sudo mkdir /etc/sv/couchdb/log

    cat > run << EOF

    !/bin/sh

    export HOME=/home/couchdb
    exec 2>&1
    exec chpst -u couchdb /home/couchdb/bin/couchdb
    EOF

    cat > log_run << EOF

    !/bin/sh

    exec svlogd -tt /var/log/couchdb
    EOF

    sudo mv ./run /etc/sv/couchdb/run
    sudo mv ./log_run /etc/sv/couchdb/log/run

    sudo chmod u+x /etc/sv/couchdb/run
    sudo chmod u+x /etc/sv/couchdb/log/run

    sudo ln -s /etc/sv/couchdb/ /etc/service/couchdb

    sleep 5
    sudo sv status couchdb

    ######## End install-couchdb.sh Script
2 Answers

@dhndeveloper

The guide should still work for Ubuntu 16.04 or Ubuntu 16.10 (16.04 being the latest LTS release that supersedes 14.04). Generally speaking, when newer releases are made (i.e. CouchDB 2.x), repository packages are updated to match, so running the commands in the guide should install the latest stable version that the maintainers of the repository have access to.

As for PouchDB, you may want to take a look at the guide below. It's recent and details how to use it combined with SQLite for local storage using Ionic.

http://gonehybrid.com/how-to-use-pouchdb-sqlite-for-local-storage-in-ionic-2/

and for general purpose, the following guide for security and authentication between CouchDB and PouchDB:

http://www.mircozeiss.com/couchdb-security-and-pouchdb-authentication

I just ran through the steps above here on both Ubuntu 14.04 and 16.04 and it installs CouchDB "1.6.1".

I found this script to install CouchDB 2.0 on Ubuntu 16.04 that works great:

https://github.com/afiskon/install-couchdb/blob/master/install-couchdb.sh

I'll be posting some additional info on configuring CouchDB 2.0 to use SSL as soon as I grind my way through it.

Have another answer? Share your knowledge.