• Get In Touch
May 16, 2017

How to Install Apache CouchDB on CentOS 7

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Apache CouchDB is a free and open source NoSQL based database management system. CouchDB is a single node database which can also be clustered to run on different servers. CouchDB uses HTTP protocol and JSON format for sending the data. Hence the database is compatible with all the software which supports this. It is very reliable and secure database management system and used by numerous web applications.

In this tutorial, we will be installing Apache CouchDB on CentOS 7 server.

Requirements

CouchDB does not require any special hardware requirements. It can be installed on servers with a small amount of RAM to very large servers according to your needs. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.

Installing CouchDB

Before installing any package it is recommended that you update the packages and repository using the following command.

yum -y update

Once the system is updated, you will need to install some dependencies which are required to install CouchDB. Some of the dependencies are not available on default YUM repository, hence you will need to install EPEL repository also. Run the following command for same.

yum -y install epel-release
yum -y update

You can install the dependencies using the following command.

yum -y install autoconf autoconf-archive automake curl-devel erlang-asn1 erlang-erts erlang-eunit erlang-os_mon erlang-xmerl help2man js-devel-1.8.5 libicu-devel libtool perl-Test-Harness erlang

Once the dependencies are installed, you can download the CouchDB source code using the following command.

cd /opt
wget http://mirror.rise.ph/apache/couchdb/source/2.0.0/apache-couchdb-2.0.0.tar.gz

If you do not have wget installed, you can run yum -y install wget. You can always check for the link to the latest version of CouchDB from download page.

Now extract the archive using the following command.

tar -xzvf apache-couchdb-2.0.0.tar.gz

Now switch to the extracted directory and configure the software using the following command.

cd apache-couchdb-2.0.0
./configure

If the script has been successfully executed, you will see the following output at the terminal.

[root@liptan-pc apache-couchdb-2.0.0]# ./configure
==> configuring couchdb in rel/couchdb.config
You have configured Apache CouchDB, time to relax. Relax.

Now build and install the software using the following command.

make release

You should get the following message at the end of the installation of everything has worked.

Installing CouchDB into rel/couchdb/ ...
==> rel (generate)
WARN:  'generate' command does not apply to directory /opt/apache-couchdb-2.0.0
... done

    You can now copy the rel/couchdb directory anywhere on your system.
    Start CouchDB with ./bin/couchdb from within that directory.

Now that you have installed the software, you will need to create a special CouchDB user to handle all CouchDB administrative tasks. Run the following command to create a CouchDB user.

adduser --system -m --shell /bin/bash --comment "CouchDB Administrator" couchdb

Now copy the CouchDB release file to the new CouchDB administrator user’s home directory using the following command.

cp -R /opt/apache-couchdb-2.0.0/rel/couchdb /home/couchdb

Now set the appropriate ownership of the file to the CouchDB user using the following command.

chown -R couchdb:couchdb /home/couchdb/couchdb

Now set the appropriate permission to CouchDB files and directories using the following command.

find /home/couchdb/couchdb -type d -exec chmod 0770 {} \;

Now set the appropriate permissions to CouchDB configuration files using the following command.

chmod 0644 /home/couchdb/couchdb/etc/*

Installation for CouchDB is now finished, you are now ready to start the server. To start the CouchDB server run the following command.

sudo -i -u couchdb /home/couchdb/couchdb/bin/couchdb

You can now access the admin panel using the following link.

http://127.0.0.1:5984/_utils/index.html

To check if everything has installed correctly, you can access the following link.

http://localhost:5984/_utils/verify_install.html

If you want CouchDB instance to start automatically, you can setup Systemd service. It is recommended to create a systemd service for running CouchDB so that it can run in the background and can be automatically started on failures and boot time. Run the following command to create a systemd service file.

nano /etc/systemd/system/couchdb.service

If you do not have nano installed, you can run yum -y install nano. Now paste the following text into the nano editor.

[Unit]
Description=CouchDB service
After=syslog.target
After=network.target

[Service]
User=couchdb
Type=simple
ExecStart=/home/couchdb/couchdb/bin/couchdb
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=couchdb

[Install] 
WantedBy=multi-user.target

Now you can start CouchDB service and configure it to automatically start at boot time using following commands.

systemctl start couchdb
systemctl enable couchdb

To check if CouchDB service is started correctly, you can run the following command to check the status of the CouchDB service.

systemctl status couchdb
You should get output similar to shown below.

[root@liptan-pc ]# systemctl status couchdb
● couchdb.service - CouchDB service
   Loaded: loaded (/etc/systemd/system/couchdb.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2017-05-12 11:28:59 UTC; 8s ago
 Main PID: 6354 (beam)
   CGroup: /system.slice/couchdb.service
           ├─6354 /home/couchdb/couchdb/bin/../erts-5.10.4/bin/beam -K true -A 16 -Bd -- -root /home/couchdb/couchdb/bin...
           ├─6381 sh -s disksup
           ├─6382 /home/couchdb/couchdb/bin/../lib/os_mon-2.2.14/priv/bin/memsup
           └─6384 /home/couchdb/couchdb/bin/../lib/os_mon-2.2.14/priv/bin/cpu_sup

May 12 11:28:59 liptan-pc couchdb[6354]: [info] 2017-05-12T11:28:59.700471Z couchdb@localhost <0.7.0> --------...lhost

By default the server will listen to localhost on port 5984 only, if you want your CouchDB instance to be accessed from everywhere you will need to edit the CouchDB configuration file, run the following command to open the configuration file with nano editor.

nano /home/couchdb/couchdb/etc/local.ini

Find the following lines into the file:

[chttpd]
;port = 5984
;bind_address = 127.0.0.1

Uncomment the lines and change the lines as shown below.

[chttpd]
port = 5984
bind_address = 0.0.0.0

Now restart the CouchDB service.

systemctl restart couchdb

Now you will need to disable your SELinux because reverse proxy does not work with SELinux policies. To temporary disable SELinux without restarting the server, run the following command.

setenforce 0

To completely disable the SELinux you will need to edit /etc/selinux/config file.

nano /etc/selinux/config

If you don’t have nano installed, you can install it using yum -y install nano Find the following line:

SELINUX=enforcing

Change it to:

SELINUX=disabled

Now you will need to reboot your server so that the new configuration can take effect. Once the server is up again you can access your application at the following URL.

http://Your-server-IP:5984/_utils/

You will see the admin panel of CouchDB.

HP_NO_IMG/data/uploads/users/5bc5f3e0-17df-4257-afd4-59fc57ecae4e/548832720.png” alt=”” />

Conclusion

In this tutorial, we learned to install CouchDB on CentOS 7. You can now use CouchDB to create and store data in NoSQL database. Make sure that you create an admin user by clicking Admin Party! option from the sidebar.

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]