1.1. Installation on Unix-like systems

Warning

CouchDB 3.0+ will not run without an admin user being created first. Be sure to create an admin user before starting CouchDB!

1.1.1. Installation using the Apache CouchDB convenience binary packages

If you are running one of the following operating systems, the easiest way to install CouchDB is to use the convenience binary packages:

  • CentOS/RHEL 7

  • CentOS/RHEL 8

  • Debian 10 (buster)

  • Debian 11 (bullseye)

  • Ubuntu 18.04 (bionic)

  • Ubuntu 20.04 (focal)

These RedHat-style rpm packages and Debian-style deb packages will install CouchDB at /opt/couchdb and ensure CouchDB is run at system startup by the appropriate init subsystem (SysV-style initd or systemd).

The Debian-style deb packages also pre-configure CouchDB as a standalone or clustered node, prompt for the address to which it will bind, and a password for the admin user. Responses to these prompts may be pre-seeded using standard debconf tools. Further details are in the README.Debian file.

For distributions lacking a compatible SpiderMonkey library, Apache CouchDB also provides packages for the 1.8.5 version.

1.1.1.1. Enabling the Apache CouchDB package repository

Debian or Ubuntu: Run the following commands:

  1. sudo apt update && sudo apt install -y curl apt-transport-https gnupg
  2. curl https://couchdb.apache.org/repo/keys.asc | gpg --dearmor | sudo tee /usr/share/keyrings/couchdb-archive-keyring.gpg >/dev/null 2>&1
  3. source /etc/os-release
  4. echo "deb [signed-by=/usr/share/keyrings/couchdb-archive-keyring.gpg] https://apache.jfrog.io/artifactory/couchdb-deb/ ${VERSION_CODENAME} main" \
  5. | sudo tee /etc/apt/sources.list.d/couchdb.list >/dev/null

RedHat or CentOS: Run the following commands:

  1. sudo yum install -y yum-utils
  2. sudo yum-config-manager --add-repo https://couchdb.apache.org/repo/couchdb.repo

1.1.1.2. Installing the Apache CouchDB packages

Debian or Ubuntu: Run the following commands:

  1. sudo apt update
  2. sudo apt install -y couchdb

Debian/Ubuntu installs from binaries can be pre-configured for single node or clustered installations. For clusters, multiple nodes will still need to be joined together and configured consistently across all machines; follow the Cluster Setup walkthrough to complete the process.

RedHat/CentOS: Run the command:

  1. sudo yum install -y couchdb

Once installed, create an admin user by hand before starting CouchDB, if your installer didn’t do this for you already.

You can now start the service.

Your installation is not complete. Be sure to complete the Setup steps for a single node or clustered installation.

Relax! CouchDB is installed and running.

1.1.1.3. GPG keys used for signing the CouchDB repositories

As of 2021.04.25, the repository signing key for both types of supported packages is:

  1. pub rsa8192 2015-01-19 [SC]
  2. 390EF70BB1EA12B2773962950EE62FB37A00258D
  3. uid The Apache Software Foundation (Package repository signing key) <root@apache.org>

As of 2021.04.25, the package signing key (only used for rpm packages) is:

  1. pub rsa4096 2017-07-28 [SC] [expires: 2022-07-27]
  2. 2EC788AE3F239FA13E82D215CDE711289384AE37
  3. uid Joan Touzet (Apache Code Signing Key) <wohali@apache.org>

As of 2021.11.13, the package signing key (only used for rpm packages) is:

  1. pub rsa4096 2019-09-05 [SC] [expires: 2039-01-02]
  2. 0BD7A98499C4AB41C910EE65FC04DFBC9657A78E
  3. uid Nicolae Vatamaniuc <vatamane@apache.org>
  4. uid default <vatamane@gmail.com>

All are available from most popular GPG key servers. The rpm signing keys should be listed in the KEYS list as well.

1.1.2. Installation from source

The remainder of this document describes the steps required to install CouchDB directly from source code.

This guide, as well as the INSTALL.Unix document in the official tarball release are the canonical sources of installation information. However, many systems have gotchas that you need to be aware of. In addition, dependencies frequently change as distributions update their archives.

1.1.3. Dependencies

You should have the following installed:

You will only need libcurl if you plan to run the JavaScript test suite. And help2man is only need if you plan on installing the CouchDB man pages. Sphinx is only required for building the online documentation. Documentation build can be disabled by adding the --disable-docs flag to the configure script.

1.1.3.1. Debian-based Systems

You can install the dependencies by running:

  1. sudo apt-get --no-install-recommends -y install \
  2. build-essential pkg-config erlang \
  3. libicu-dev libmozjs185-dev libcurl4-openssl-dev

Be sure to update the version numbers to match your system’s available packages.

1.1.3.2. RedHat-based (Fedora, CentOS, RHEL) Systems

You can install the dependencies by running:

  1. sudo yum install autoconf autoconf-archive automake \
  2. curl-devel erlang-asn1 erlang-erts erlang-eunit gcc-c++ \
  3. erlang-os_mon erlang-xmerl erlang-erl_interface help2man \
  4. libicu-devel libtool perl-Test-Harness

Warning: To build a release for CouchDB the erlang-reltool package is required, yet on CentOS/RHEL this package depends on erlang-wx which pulls in wxGTK and several X11 libraries. If CouchDB is being built on a console only server it might be a good idea to install this in a separate step to the rest of the dependencies, so that the package and all its dependencies can be removed using the yum history tool after the release is built. (reltool is needed only during release build but not for CouchDB functioning)

The package can be installed by running:

  1. sudo yum install erlang-reltool

1.1.3.3. Mac OS X

Follow Installation with Homebrew reference for Mac App installation.

If you are installing from source, you will need to install the Command Line Tools:

  1. xcode-select --install

You can then install the other dependencies by running:

  1. brew install autoconf autoconf-archive automake libtool \
  2. erlang icu4c spidermonkey curl pkg-config

You will need Homebrew installed to use the brew command.

Some versions of Mac OS X ship a problematic OpenSSL library. If you’re experiencing troubles with CouchDB crashing intermittently with a segmentation fault or a bus error, you will need to install your own version of OpenSSL. See the wiki, mentioned above, for more information.

See also

1.1.3.4. FreeBSD

FreeBSD requires the use of GNU Make. Where make is specified in this documentation, substitute gmake.

You can install this by running:

  1. pkg install gmake

1.1.4. Installing

Once you have satisfied the dependencies you should run:

  1. ./configure

If you wish to customize the installation, pass --help to this script.

If everything was successful you should see the following message:

  1. You have configured Apache CouchDB, time to relax.

Relax.

To build CouchDB you should run:

  1. make release

Try gmake if make is giving you any problems.

If include paths or other compiler options must be specified, they can be passed to rebar, which compiles CouchDB, with the ERL_CFLAGS environment variable. Likewise, options may be passed to the linker with the ERL_LDFLAGS environment variable:

  1. make release ERL_CFLAGS="-I/usr/local/include/js -I/usr/local/lib/erlang/usr/include"

If everything was successful you should see the following message:

  1. ... done
  2. You can now copy the rel/couchdb directory anywhere on your system.
  3. Start CouchDB with ./bin/couchdb from within that directory.

Relax.

Note: a fully-fledged ./configure with the usual GNU Autotools options for package managers and a corresponding make install are in development, but not part of the 2.0.0 release.

1.1.5. User Registration and Security

For OS X, in the steps below, substitute /Users/couchdb for /home/couchdb.

You should create a special couchdb user for CouchDB.

On many Unix-like systems you can run:

  1. adduser --system \
  2. --shell /bin/bash \
  3. --group --gecos \
  4. "CouchDB Administrator" couchdb

On Mac OS X you can use the Workgroup Manager to create users up to version 10.9, and dscl or sysadminctl after version 10.9. Search Apple’s support site to find the documentation appropriate for your system. As of recent versions of OS X, this functionality is also included in Server.app, available through the App Store only as part of OS X Server.

You must make sure that the user has a working POSIX shell and a writable home directory.

You can test this by:

  • Trying to log in as the couchdb user

  • Running pwd and checking the present working directory

As a recommendation, copy the rel/couchdb directory into /home/couchdb or /Users/couchdb.

Ex: copy the built couchdb release to the new user’s home directory:

  1. cp -R /path/to/couchdb/rel/couchdb /home/couchdb

Change the ownership of the CouchDB directories by running:

  1. chown -R couchdb:couchdb /home/couchdb

Change the permission of the CouchDB directories by running:

  1. find /home/couchdb -type d -exec chmod 0770 {} \;

Update the permissions for your ini files:

  1. chmod 0644 /home/couchdb/etc/*

1.1.6. First Run

Note

Be sure to create an admin user before trying to start CouchDB!

You can start the CouchDB server by running:

  1. sudo -i -u couchdb /home/couchdb/bin/couchdb

This uses the sudo command to run the couchdb command as the couchdb user.

When CouchDB starts it should eventually display following messages:

  1. {database_does_not_exist,[{mem3_shards,load_shards_from_db,"_users" ...

Don’t be afraid, we will fix this in a moment.

To check that everything has worked, point your web browser to:

  1. http://127.0.0.1:5984/_utils/index.html

From here you should verify your installation by pointing your web browser to:

  1. http://localhost:5984/_utils/index.html#verifyinstall

Your installation is not complete. Be sure to complete the Setup steps for a single node or clustered installation.

1.1.7. Running as a Daemon

CouchDB no longer ships with any daemonization scripts.

The CouchDB team recommends runit to run CouchDB persistently and reliably. According to official site:

runit is a cross-platform Unix init scheme with service supervision, a replacement for sysvinit, and other init schemes. It runs on GNU/Linux, *BSD, MacOSX, Solaris, and can easily be adapted to other Unix operating systems.

Configuration of runit is straightforward; if you have questions, contact the CouchDB user mailing list or IRC-channel #couchdb in FreeNode network.

Let’s consider configuring runit on Ubuntu 18.04. The following steps should be considered only as an example. Details will vary by operating system and distribution. Check your system’s package management tools for specifics.

Install runit:

  1. sudo apt-get install runit

Create a directory where logs will be written:

  1. sudo mkdir /var/log/couchdb
  2. sudo chown couchdb:couchdb /var/log/couchdb

Create directories that will contain runit configuration for CouchDB:

  1. sudo mkdir /etc/sv/couchdb
  2. sudo mkdir /etc/sv/couchdb/log

Create /etc/sv/couchdb/log/run script:

  1. #!/bin/sh
  2. exec svlogd -tt /var/log/couchdb

Basically it determines where and how exactly logs will be written. See man svlogd for more details.

Create /etc/sv/couchdb/run:

  1. #!/bin/sh
  2. export HOME=/home/couchdb
  3. exec 2>&1
  4. exec chpst -u couchdb /home/couchdb/bin/couchdb

This script determines how exactly CouchDB will be launched. Feel free to add any additional arguments and environment variables here if necessary.

Make scripts executable:

  1. sudo chmod u+x /etc/sv/couchdb/log/run
  2. sudo chmod u+x /etc/sv/couchdb/run

Then run:

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

In a few seconds runit will discover a new symlink and start CouchDB. You can control CouchDB service like this:

  1. sudo sv status couchdb
  2. sudo sv stop couchdb
  3. sudo sv start couchdb

Naturally now CouchDB will start automatically shortly after system starts.

You can also configure systemd, launchd or SysV-init daemons to launch CouchDB and keep it running using standard configuration files. Consult your system documentation for more information.