2.1. Installation on Unix-like systems
2.1.1. Installation using the Apache CouchDB convenience binary packages
If you are running one of the following operating systems, the easiest wayto install CouchDB is to use the convenience binary packages:
- CentOS/RHEL 6
- CentOS/RHEL 7
- Debian 8 (jessie)
- Debian 9 (stretch)
- Ubuntu 14.04 (trusty)
- Ubuntu 16.04 (xenial)
- Ubuntu 18.04 (bionic)
The RedHat-style rpm packages and Debian-style deb packages will installCouchDB at/opt/couchdb
and ensure CouchDB is run at system startup by theappropriate init subsystem (SysV-style initd, upstart, systemd).
The Debian-style deb packages also pre-configure CouchDB as a standalone orclustered node, prompt for the address to which it will bind, and a passwordfor the admin user. Responses to these prompts may be pre-seeded using standarddebconf tools. Further details are in the README.Debian file.
Apache CouchDB also provides packages for the SpiderMonkey 1.8.5 JavaScriptdependency, as the upstream packages for this shared library are starting todisappear or become unreliable.
2.1.1.1. Enabling the Apache CouchDB package repository
CentOS: Place the following text into /etc/yum.repos.d/bintray-apache-couchdb-rpm.repo
:
- [bintray--apache-couchdb-rpm]
- name=bintray--apache-couchdb-rpm
- baseurl=http://apache.bintray.com/couchdb-rpm/el$releasever/$basearch/
- gpgcheck=0
- repo_gpgcheck=0
- enabled=1
RedHat/RHEL: Place the following text into /etc/yum.repos.d/bintray-apache-couchdb-rpm.repo
. Be sure to replace the 7
below with 6
if you are on a EL6 distribution:
- [bintray--apache-couchdb-rpm]
- name=bintray--apache-couchdb-rpm
- baseurl=http://apache.bintray.com/couchdb-rpm/el7/$basearch/
- gpgcheck=0
- repo_gpgcheck=0
- enabled=1
Debian/Ubuntu: Run the command:
- $ echo "deb https://apache.bintray.com/couchdb-deb {distribution} main" \
- | sudo tee -a /etc/apt/sources.list
and replace {distribution}
with the appropriate choice for your OSversion:
- Debian 8:
jessie
- Debian 9:
stretch
- Ubuntu 14.04:
trusty
- Ubuntu 16.04:
xenial
- Ubuntu 18.04:
bionic
2.1.1.2. Installing the Apache CouchDB packages
RedHat/CentOS: Run the command:
- $ sudo yum -y install epel-release && yum install couchdb
Your installation is not complete. Be sure to complete theSetupsteps for a single node or clustered installation.
Debian/Ubuntu: First, install the repository key:
- $ curl -L https://couchdb.apache.org/repo/bintray-pubkey.asc \
- | sudo apt-key add -
Then update the repository cache and install the package:
- $ sudo apt-get update && sudo apt-get install couchdb
Debian/Ubuntu installs from binaries will be pre-configured for single node orclustered installations. For clusters, multiple nodes will still need to bejoined together and configured consistently across all machines; follow theCluster Setupwalkthrough to complete the process.
Relax! CouchDB is installed and running.
2.1.2. Installation from source
The remainder of this document describes the steps required to install CouchDBdirectly from source code.
This guide, as well as the INSTALL.Unix document in the official tarballrelease are the canonical sources of installation information. However, manysystems have gotchas that you need to be aware of. In addition, dependenciesfrequently change as distributions update their archives.
2.1.3. Dependencies
You should have the following installed:
- Erlang OTP (>=R16B03, =<19.x)
- ICU
- OpenSSL
- Mozilla SpiderMonkey (1.8.5)
- GNU Make
- GNU Compiler Collection
- libcurl
- help2man
- Python (>=2.7) for docs
- Python Sphinx (>=1.1.3)
It is recommended that you install Erlang OTP R16B03-1 or above where possible.You will only need libcurl if you plan to run the JavaScript test suite. Andhelp2man is only need if you plan on installing the CouchDB man pages.Python and Sphinx are only required for building the online documentation.Documentation build can be disabled by adding the—disable-docs
flag totheconfigure
script.
2.1.3.1. Debian-based Systems
You can install the dependencies by running:
- sudo apt-get --no-install-recommends -y install \
- build-essential pkg-config erlang \
- libicu-dev libmozjs185-dev libcurl4-openssl-dev
Be sure to update the version numbers to match your system’s availablepackages.
2.1.3.2. RedHat-based (Fedora, Centos, RHEL) Systems
You can install the dependencies by running:
- sudo yum install autoconf autoconf-archive automake \
- curl-devel erlang-asn1 erlang-erts erlang-eunit gcc-c++ \
- erlang-os_mon erlang-xmerl erlang-erl_interface help2man \
- js-devel-1.8.5 libicu-devel libtool perl-Test-Harness
While CouchDB builds against the default js-devel-1.7.0 included in somedistributions, it’s recommended to use a more recent js-devel-1.8.5.
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 wxGTKand several X11 libraries. If CouchDB is being built on a console onlyserver it might be a good idea to install this in a separate step to therest of the dependencies, so that the package and all its dependenciescan 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:
- sudo yum install erlang-reltool
2.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 CommandLine Tools:
- xcode-select --install
You can then install the other dependencies by running:
- brew install autoconf autoconf-archive automake libtool \
- 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. Ifyou’re experiencing troubles with CouchDB crashing intermittently witha segmentation fault or a bus error, you will need to install your ownversion of OpenSSL. See the wiki, mentioned above, for more information.
See also
2.1.3.4. FreeBSD
FreeBSD requires the use of GNU Make. Where make
is specified in thisdocumentation, substitute gmake
.
You can install this by running:
- pkg install gmake
2.1.4. Installing
Once you have satisfied the dependencies you should run:
- ./configure
If you wish to customize the installation, pass —help
to this script.
If everything was successful you should see the following message:
- You have configured Apache CouchDB, time to relax.
Relax.
To build CouchDB you should run:
- 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:
- 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:
- ... done
- You can now copy the rel/couchdb directory anywhere on your system.
- Start CouchDB with ./bin/couchdb from within that directory.
Relax.
Note: a fully-fledged ./configure
with the usual GNU Autotools optionsfor package managers and a corresponding make install
are indevelopment, but not part of the 2.0.0 release.
2.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:
- adduser --system \
- --shell /bin/bash \
- --group --gecos \
- "CouchDB Administrator" couchdb
On Mac OS X you can use the Workgroup Manager to create users up to version10.9, and dscl or sysadminctl after version 10.9. Search Apple’s supportsite to find the documentation appropriate for your system. As of recentversions 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 writablehome 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 therel/couchdb
directory into/home/couchdb
or/Users/couchdb
.
Ex: copy the built couchdb release to the new user’s home directory:
- cp -R /path/to/couchdb/rel/couchdb /home/couchdb
Change the ownership of the CouchDB directories by running:
- chown -R couchdb:couchdb /home/couchdb
Change the permission of the CouchDB directories by running:
- find /home/couchdb -type d -exec chmod 0770 {} \;
Update the permissions for your ini files:
- chmod 0644 /home/couchdb/etc/*
2.1.6. First Run
You can start the CouchDB server by running:
- sudo -i -u couchdb /home/couchdb/bin/couchdb
This uses the sudo
command to run the couchdb
command as thecouchdb
user.
When CouchDB starts it should eventually display following messages:
- {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:
- http://127.0.0.1:5984/_utils/index.html
From here you should verify your installation by pointing your web browser to:
- http://localhost:5984/_utils/index.html#verifyinstall
Your installation is not complete. Be sure to complete theSetupsteps for a single node or clustered installation.
2.1.7. Running as a Daemon
CouchDB no longer ships with any daemonization scripts.
The CouchDB team recommends runit torun 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 onGNU/Linux, *BSD, MacOSX, Solaris, and can easily be adapted toother Unix operating systems.
Configuration of runit is straightforward; if you have questions, contactthe CouchDB user mailing listor IRC-channel #couchdbin FreeNode network.
Let’s consider configuring runit on Ubuntu 16.04. The followingsteps should be considered only as an example. Details will varyby operating system and distribution. Check your system’s packagemanagement tools for specifics.
Install runit:
- sudo apt-get install runit
Create a directory where logs will be written:
- sudo mkdir /var/log/couchdb
- sudo chown couchdb:couchdb /var/log/couchdb
Create directories that will contain runit configuration for CouchDB:
- sudo mkdir /etc/sv/couchdb
- sudo mkdir /etc/sv/couchdb/log
Create /etc/sv/couchdb/log/run script:
- #!/bin/sh
- 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:
- #!/bin/sh
- export HOME=/home/couchdb
- exec 2>&1
- 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 environmentvariables here if necessary.
Make scripts executable:
- sudo chmod u+x /etc/sv/couchdb/log/run
- sudo chmod u+x /etc/sv/couchdb/run
Then run:
- 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:
- sudo sv status couchdb
- sudo sv stop couchdb
- 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 launchCouchDB and keep it running using standard configuration files. Consultyour system documentation for more information.