Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duhaime/d8c4179339acea9b3f1e9eedf463d8f6 to your computer and use it in GitHub Desktop.
Save duhaime/d8c4179339acea9b3f1e9eedf463d8f6 to your computer and use it in GitHub Desktop.
Installing CouchDB 1.6.1 and Apache2 on Ubuntu 14.04
# Steps to install CouchDB 1.6.1 and Apache2 on Ubuntu 14.04
# On AWS, select the Ubuntu 14.04 standard box (ami-2d39803a)
# edit security groups to add the "HTTP" rule, which exposes port 80 to traffic from 0.0.0.0
# then add a "Custom TCP rule", exposing port 5984 to traffic from 0.0.0.0
# launch and ssh to the instance
# become root
sudo -s
# update apt-get and install dependencies
apt-get update
apt-get install -y erlang-dev erlang-manpages erlang-base-hipe erlang-eunit erlang-nox erlang-xmerl erlang-inets build-essential curl git apache2
apt-get install -y libmozjs185-dev libicu-dev libcurl4-gnutls-dev libtool python-software-properties python g++ make python-pip
# make an install directory for couchdb
mkdir couchdb;cd couchdb
# obtain and unzip couchdb source code
wget http://apache.mirrors.tds.net/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz
tar -zxf apache-couchdb-1.6.1.tar.gz
# enter the couchdb directory and install the source code
cd apache-couchdb-1.6.1/
./configure;make
make install
# create a couchdb user and change file permissions for that user
useradd -d /var/lib/couchdb couchdb
chown -R couchdb:couchdb /usr/local/var/lib/couchdb/
chown -R couchdb:couchdb /usr/local/var/log/couchdb/
chown -R couchdb:couchdb /usr/local/var/run/couchdb/
# make couchdb run as a service
ln -s /usr/local/etc/init.d/couchdb /etc/init.d
# make couchdb start at runtime
update-rc.d couchdb defaults
update-rc.d couchdb enable
# verify the service will start at runtime by running rcconf or sysv-rc-conf
aptitude install rcconf sysv-rc-conf -y
# run the rcfonf tool (select couchdb)
rcconf
# change the bind_address (under httpd) for CouchDB configuration to 0.0.0.0
vim /usr/local/etc/couchdb/default.ini
# restart couchdb
/etc/init.d/couchdb restart
# test the install
curl localhost:5984
# test whether port 5984 is exposed to external traffic. If not (and you want to expose that port), go to next section
curl {{public ip of box}}:5984
########
# CORS #
########
# verify there is a service (couchdb) listening on port 5984
netstat -a grep 5984
# add CORS support to apache2. first, enable headers
a2enmod headers
# then add CORS headers
vim /etc/apache2/apache2.conf
-> under <Directory /var/www/>, add:
`Header set Access-Control-Allow-Origin "*"`
# add CORS support to couchdb
vim /usr/local/etc/couchdb/default.ini
-> under[httpd] add:
`enable_cors = true`
-> at the end of the file, add:
[cors]
origins = *
credentials = true
methods = GET, PUT, POST, HEAD, DELETE
headers = accept, authorization, content-type, origin, referer, x-csrf-token
# restart apache2 and couchdb
service apache2 restart
/etc/init.d/couchdb restart
# validate that port 5984 is exposed to external traffic. Navigate in a browser to:
{{your instance's public ip}}:5984
# from here, restrict access to port 5984 as you see fit by updating your security settings for the instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment