Apache CouchDB is an open-source NoSQL database management system that stores data in a schema-less JSON format, allowing for flexible and dynamic data modeling. Apache CouchDB offers organizations a robust and flexible NoSQL database solution with features such as distributed architecture, document-oriented storage, offline-first capabilities, RESTful API, and fault tolerance. By leveraging CouchDB, organizations can build scalable, resilient, and responsive applications that meet the demands of modern data-driven environments.

In this tutorial, we will show you how to install Apache CouchDB on Ubuntu 22.04.

Step 1 – Install Apache CouchDB

To install Apache CouchDB on Ubuntu 22.04, you’ll need to add the CouchDB repository to your system.

CouchDB provides a GPG key that is used to sign the repository packages. You can download and install this key using the following command:

curl https://couchdb.apache.org/repo/keys.asc | gpg --dearmor | sudo tee /usr/share/keyrings/couchdb-archive-keyring.gpg >/dev/null

Next, add the CouchDB repository to your system’s software sources list. You can create a new file for the CouchDB repository in the /etc/apt/sources.list.d/ directory:

echo "deb [signed-by=/usr/share/keyrings/couchdb-archive-keyring.gpg] https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/couchdb.list

After adding the repository, update the package lists to ensure that Ubuntu recognizes the newly added CouchDB repository:

apt-get update -y

Once the repository is added and the package lists are updated, you can install CouchDB using the apt package manager:

apt-get install couchdb -y

You will be asked to install CouchDB in standalone or clustered mode.

Select Standalone and press the Enter key. You will be asked to set the Erlang value:

Set your desired value and press the Enter key. You will be asked to set a bind address:

Set your bind address and press the Enter key. You will be asked to set admin password.

Define your password and press the Enter key to complete the installation.

Step 2 – Configure Apache CouchDB

By default, Apache CouchDB listens on localhost on port 5984. To access CouchDB from an external system, you will need to edit the CouchDB configuration file to define a band address.

nano /opt/couchdb/etc/local.ini

Change the following lines:

[chttpd]
port = 5984
bind_address = 0.0.0.0

Save and close the file then start the CouchDB service.

systemctl start couchdb

You can check the status of CouchDB using the following command:

systemctl status couchdb

Output:

● couchdb.service - Apache CouchDB
     Loaded: loaded (/lib/systemd/system/couchdb.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2024-04-06 03:24:56 UTC; 48s ago
   Main PID: 14158 (beam.smp)
      Tasks: 28 (limit: 4579)
     Memory: 43.0M
        CPU: 5.853s
     CGroup: /system.slice/couchdb.service
             ├─14158 /opt/couchdb/bin/../erts-12.3.2.15/bin/beam.smp -SDio 16 -Bd -- -root /opt/couchdb/bin/.. -progname couchdb -- -home /opt/couchdb -- -boot /opt/co>
             ├─14171 /opt/couchdb/bin/../erts-12.3.2.15/bin/epmd -daemon
             └─14174 erl_child_setup 65536

Step 3 – Verifying the Installation

To verify the installation of CouchDB, use the curl command:

curl http://127.0.0.1:5984/

Output:

{"couchdb":"Welcome","version":"3.3.3","git_sha":"40afbcfc7","uuid":"7f98ad06b2538ed9b4d6843bd6b5c07d","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}

Conclusion

Following the steps outlined in this guide, users can quickly set up CouchDB on their Ubuntu systems and begin leveraging its powerful data storage, retrieval, and synchronization features. Apache CouchDB is suitable for many use cases, from web and mobile applications to data synchronization hubs and offline-first solutions. You can now use CouchDB as a database backend on dedicated server hosting from Atlantic.Net!