How to Install CouchDB on CentOS 7

By 

Published on

3 min read

Install CouchDB on CentOS 7

Apache CouchDB is a free and open-source NoSQL database developed by the Apache Software Foundation.

CouchDB server stores its data in named databases which contains documents with JSON structure. Each document consists of a number of fields and attachments. Fields can include text, numbers, lists, booleans, more. It includes a RESTful HTTP API that allows you to read, create, edit and delete database documents.

In this tutorial, we will explain how to install the latest version of CouchDB on CentOS 7.

Prerequisites

To be able to install new packages on your CentOS system, you must be logged in as a user with sudo privileges .

Enable CouchDB Repository

The CouchDB repository depends on the EPEL repository . If the EPEL repository is not enabled on your system, enable it by typing:.

Terminal
sudo yum install epel-release

Next, open your editor of choice and create the CouchDB repository file:

Terminal
sudo nano /etc/yum.repos.d/bintray-apache-couchdb-rpm.repo

Paste the following content into the file:

/etc/yum.repos.d/bintray-apache-couchdb-rpm.repoini
[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

Save the file and close the editor.

Install CouchDB on CentOS

Now that the repository is enabled, you can install the CouchDB packages using the following command:

Terminal
sudo yum install couchdb

Once the installation is completed, enable and start the CouchDB service:

Terminal
sudo systemctl start couchdb
sudo systemctl enable couchdb

By default, CouchDB listens on localhost only and no admin account is created.

Apache CouchDB data and configuration files are stored in the /opt/couchdb directory. To create an admin account open the local.ini file and add a line under the [admins] section in the format username = password.

Terminal
sudo nano /opt/couchdb/etc/local.ini
/opt/couchdb/etc/local.iniini
[admins]
admin = mysecretpassword

Transform the password to a hash, by restarting the CouchDB service:

Terminal
sudo systemctl restart couchdb

Use the same format to add multiple admin accounts. You’ll need to restart the CouchDB service after adding a new account.

Use curl to create the system databases: _users, _replicator and _global_changes :

Terminal
curl -u ADMINUSER:PASS -X PUT http://127.0.0.1:5984/_users
curl -u ADMINUSER:PASS -X PUT http://127.0.0.1:5984/_replicator
curl -u ADMINUSER:PASS -X PUT http://127.0.0.1:5984/_global_changes

Each command should return the following:

output
{"ok":true}

Verifying CouchDB Installation

To verify whether the installation was performed successfully, issue the following curl command that will print the CouchDB database information in JSON format:

Terminal
curl http://127.0.0.1:5984/

For clarity the output below is formatted.

output
{  
   "couchdb":"Welcome",
   "version":"2.3.1",
   "git_sha":"c298091a4",
   "uuid":"17a6b911e0d5bfe36778b387510dbd93",
   "features":[  
      "pluggable-storage-engines",
      "scheduler"
   ],
   "vendor":{  
      "name":"The Apache Software Foundation"
   }
}

If you prefer GUI, you can access the CouchDB web-based interface, Fauxton at:

url
http://127.0.0.1:5984/_utils/
CouchDB Fauxton

Conclusion

You have learned how to install CouchDB CentOS 7. Your next step could be to visit the Apache CouchDB Documentation and find more information on this topic.

Feel free to leave a comment if you have any questions.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page