Install Apache CouchDB on Ubuntu

By Chandrashekhar Fakirpure

Updated on May 09, 2024

In this article, we will explain how to install Apache CouchDB on Ubuntu on 22.04. A popular open-source NoSQL database system and provides a RESTful HTTP API for data access.

CouchDB is known for its distributed architecture, incremental replication, and robust support for multi-master setups. CouchDB stores data in JSON documents, making it flexible and schema-free. Each document is uniquely identified by its ID.

CouchDB provides a comprehensive HTTP API for interacting with databases, documents, and views. This allows you to perform CRUD (Create, Read, Update, Delete) operations and execute queries using simple HTTP requests.

Install Apache CouchDB on Ubuntu

Let's start with the installation process.

Prerequisites:

  • A Ubuntu 22.04 installed dedicated server or KVM VPS
  • A root user access or normal user with sudoer rights (In this case use sudo in front of every command). 

1. Install dependencies:

First, we need to install dependencies using following command:

apt install curl apt-transport-https gnupg -y

2. Enabling the Apache CouchDB package repository

Next, we need to enable package repository because is not present the default packages. Execute following set of commands:

curl https://couchdb.apache.org/repo/keys.asc | gpg --dearmor | sudo tee /usr/share/keyrings/couchdb-archive-keyring.gpg >/dev/null 2>&1
echo "deb [signed-by=/usr/share/keyrings/couchdb-archive-keyring.gpg] https://apache.jfrog.io/artifactory/couchdb-deb/ jammy  main" | sudo tee /etc/apt/sources.list.d/couchdb.list >/dev/null

Update the repository.

apt update

Finally, let's execute following command to install Apache CouchDB:

apt install couchdb -y

Note: It will ask the set of information like 

  • Installation Type: Use standalone
  • Magic cookie: Use random string
  • Bind address: Use localhost address 127.0.0.1
  • Admin password: Use strong admin password and save it, we need it to login into the panel.

Once you fill out the information, the installation gets completed. 

3. Configuring Nginx

Next, let's install and configure Nginx.

Install Nginx 

apt install nginx -y

Now, create new Nginx configuration file.

nano /etc/nginx/sites-available/couchdb.conf

Add following contents:

server {
     listen 80;
     server_name couchdb.example.com;

     location / {
       proxy_pass         http://localhost:5984;
       proxy_redirect     off;

       proxy_set_header   Host              $host;
       proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
       proxy_set_header   X-Forwarded-Proto $scheme;

     }
}

Note: Replace couchdb.example.com with your referred domain name. If you have choosen different port for CouchDB, replace 5984 port with your port number

Save and exit.

Next, create a symbolic link to activate the newly created configuration file.

ln -s /etc/nginx/sites-available/couchdb.conf /etc/nginx/sites-enabled/

Test the Nginx configurations using following command:

nginx -t

Finally, restart the Nginx service to reflect the changes.

systemctl restart nginx

4. Configuring Firewall

Now, let's configure the firewall. We need to add HTTP and HTTPS ports in the firewall. 

ufw allow {80,443}/tcp

Restart the UFW firewall to save the table.

ufw reload

5. Installing SSL

We will install the SSL certificate to the domain name using Certbot Let's Encrypt. Execute the following command:

snap install certbot --classic

Now, obtain the certificate.

certbot --nginx -d couchdb.example.com

It will ask you to fill our your email id.

To renew the SSL certificate automatically, execute the following command:

certbot renew --dry-run

6. Accessing Web Panel

To access the web panel, navigate to _utils/ directory.

https://couch.example.com/_utils/

It will ask the username and password, fill out the admin user and password we have set during the installation process.

That's it. We have successfully install Apache CouchDB on Ubuntu on 22.04.