Me Health CH
Published © Apache-2.0

Installing CouchDB on Raspbian Stretch

This is a step by step explanation on how to install CouchDB 2.x on Raspbian Stretch.

BeginnerProtip30 minutes4,485
Installing CouchDB on Raspbian Stretch

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B

Software apps and online services

Raspberry Pi Raspbian Stretch


Read more


Shell Command Summary

# 2. Prerequisite for the Raspberry Pi. #

	cat /etc/os-release
	# PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
	# NAME="Raspbian GNU/Linux"
	# VERSION="9 (stretch)"
	# ID=raspbian
	# ID_LIKE=debian
	# HOME_URL=""
	sudo apt-get update
	sudo apt-get dist-upgrade


# 3. Download, build and install software. #

	sudo apt-key add erlang_solutions.asc
	sudo apt-get update
	sudo apt-get --no-install-recommends -y install build-essential \
	pkg-config erlang libicu-dev \
	libmozjs185-dev libcurl4-openssl-dev
	sudo useradd -d /home/couchdb couchdb
	sudo mkdir /home/couchdb
	sudo chown couchdb:couchdb /home/couchdb
	tar zxvf apache-couchdb-2.1.1.tar.gz
	cd apache-couchdb-2.1.1/
	make release
	cd ./rel/couchdb/
	sudo cp -Rp * /home/couchdb
	sudo chown -R couchdb:couchdb /home/couchdb
	rm -R apache-couchdb-2.1.1/
	rm apache-couchdb-2.1.1.tar.gz
	rm erlang_solutions.asc


# 4. First run and check. #

For remote access:

	sudo nano /home/couchdb/etc/local.ini

=> change line

	#bind_address =


	bind_address =

(! not prefixed by # !)

Now, you are ready to run CouchDB as couchdb user with:
	sudo -i -u couchdb /home/couchdb/bin/couchdb


# 5. Script for running CouchDB on boot. #

	mkdir /var/log/couchdb/
	sudo chown couchdb:couchdb /var/log/couchdb
Then, be sure that CouchDB is still running and in your Browser go into the Configuration page: []( If you have defined an administrator you should be logged in as the administrator.

Click on the +Add Option and fill the form like here:

values are:

- `log` for Section,
- `file` for Name and 
- `/var/log/couchdb/couch.log` for Value.

Click on Create.

Now, create the service by editing a new file:

	sudo nano /lib/systemd/system/couchdb.service

and paste the following to the content of the editor:

	Description=CouchDB Service
Then, fix file permissions with:

	sudo chmod 644 /lib/systemd/system/couchdb.service

and instruct systemd to start the service during the boot sequence:

	sudo systemctl daemon-reload
	sudo systemctl enable couchdb.service

When you reboot the Pi the couchdb service should run:

	sudo reboot

and check service status using:

	sudo systemctl status couchdb.service

Also, either browse to page http://localhost:5984 to check that CouchDB server is up and running, or execute in your terminal:

	curl http://localhost:5984

which should reply something like :

	{"couchdb":"Welcome","version":"2.1.1","features":["scheduler"],"vendor":{"name":"The Apache Software Foundation"}}

Now, you are ready to enjoy all CouchDB server capabilities !

Have a look to CouchDB Documentation and enjoy PouchDB in your browser, mobile or NodeJS projects.

Your Feedback and suggestions for improvements would be welcome !  


Me Health CH

Me Health CH

1 project • 0 followers
eHealth R&D, mobile and personal health, medical informatics research and development