How to Install Apache CouchDB in Ubuntu 22.04

Learn how to install Apache CouchDB in Ubuntu 22.04 to get started with the basic administration operations on the DB.

Install Apache CouchDB in Ubuntu 22.04
Install Apache CouchDB in Ubuntu 22.04

Apache CouchDB is an open-source non-relational database released in 2005 by the Apache Software Foundation. It focuses on the storage of data in JSON format. This database is made with Erlang, which makes it scalable with a user-friendly experience. It is ideal for web-based applications that require a flexible solution for storing and retrieving data. CouchDB allows production databases to run smoothly with non-interrupted operations regardless of fluctuations in request volume and performance issues.

Get $200 free to Explore the Cloud.

This blog post will show the steps required to implement the CouchDB database server on Ubuntu 22.04. You might also like the MongoDB database

Prerequisites

Before proceeding, make sure you have:

  • Ubuntu 20.04 installed
  • A non-root sudouser

With that out of the way, let us get started.

Package updates and dependency installation

In the terminal, run the following command to update the packages database.

sudo apt update

The next step is to install the required dependencies. Do so with the command below.

sudo apt install -y curl apt-transport-https gnupg

Configuring the CouchDB repository and Key

  1. Copy the following command and paste it on your terminal.

    curl https://couchdb.apache.org/repo/keys.asc | gpg --dearmor | sudo tee /usr/share/keyrings/couchdb-archive-keyring.gpg >/dev/null 2>&1 source /etc/os-release
    

    This command should download the CouchDB gpg package key to allow the apt tool to trust the third-party repository.

  2. The next step is to add the CouchDB repository to the list of downloadable packages with the command below.

    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
    
  3. Update the package database once more to refresh the new repository entry.

    sudo apt update
    

CouchDB installation

  1. With the repository ready, install the CouchDB database with the following code and press Enter.

    sudo apt install -y couchdb
    

    The installation will prompt you with a few questions:

  2. The first prompt asks for the type of CouchDB configuration:

    General type of CouchDB configuration:   
    
        standalone
        clustered
        none 
    

    For demonstration purposes, the standalone option is the way to go considering that the DB is installed in a single server.

    Use the up/down arrow keys to choose the option that fits your needs accordingly, and press Enter.

    Standalone: With this option, only one server is involved.

    Clustered: This option has multiple interconnected servers that work together as retrievable data repository.

  3. The next prompt asks for the Erlang magic cookie value. You can type anything here but make sure that the value matches for all nodes in the cluster. The Erlang magic cookie is a unique identifier for the clusters. In this case, I use Geek as the magic cookie.
    Img-1-3

  4. In the next prompt, Enter the target IP address.

CouchDB interface bind address:            
127.0.0.1
Leave the IP address to default `127.0.0.1` for the standalone installation and press `Enter`
  1. You are then prompted for an administration password.

    Password for the CouchDB "admin" user:  
    EXAMPLE_PASSWORD
    

    Type in your password and re-type it again for confirmation and press Enter.

    Leave the installation process to finish, and you are done.

Verify the Installation

You can confirm the installation was successful and the service is running with the following command.

curl http://127.0.0.1:5984/

The server will be running on the port 5984.

Img-3-2

You can also check using the command below to check the status:

sudo systemctl status couchdb

Img-4-2

Managing the CouchDB

You can use the following commands to manage the CouchDB package.

Starting the Service:

sudo systemctl start couchdb

Stopping the Service:

sudo systemctl stop couchdb

Enabling the CouchDB service to start at boot:

sudo systemctl enable couchdb

Restarting the CouchDB service:

sudo systemctl restart couchdb

Accessing CouchDB Web Interface

You can access the Apache CouchDB web interface by visiting http://127.0.0.1:5984/_utils/. This works for local machines. However, follow the steps below if you have set this up remotely.

  1. Start by opening /opt/couchdb/etc/local.ini file with nano.

    sudo nano /opt/couchdb/etc/local.ini
    
  2. Find the ; character in ;bind_address = 127.0.0.1entry.

    ...
    
    [chttpd]
    ;port = 5984
    ;bind_address = 127.0.0.1
    
    ...
    
  3. Remove the ; character from the bind_address to uncomment it. Change its value from 127.0.0.1 to 0.0.0.0. This will allow CouchDB to listen to all networks.

    This is how it should look.

    ...
    
    [chttpd]
    ;port = 5984
    bind_address = 0.0.0.0
    
    ...
    
  4. Save the file and restart the CouchDB server to apply the changes.

    sudo systemctl restart couchdb
    
  5. You can now visit the url http://URL:5984/_utils/. Where URL is your servers' IP address.

  6. After going to the URL, you see the login screen.

    Img-5-1

To login to your Fauxton control panel, use the user credentials set earlier with "username" set as "admin"

Conclusion

This article shows a walk-through for the installation of the Apache CouchDB on Ubuntu 22.04. After the installation, you can perform the basic CRUD functions using the CouchDB to manage your files and documents.

If you found the article helpful, consider sharing it and subscribing to geekbits.

Thank you for reading :)

If you enjoy our content, please consider buying us a coffee to support our work:

Table of Contents
Great! Next, complete checkout for full access to GeekBits.
Welcome back! You've successfully signed in.
You've successfully subscribed to GeekBits.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.