Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash script that installs CouchDB on Amazon Linux EC2 (2015.09)
#!/bin/bash
#This script is tuned to install CouchDB on an Amazon Linux (2015.09) EC2 Instance
#Documented here:
#https://cwiki.apache.org/confluence/display/COUCHDB/Amazon+Linux
#Install tools
sudo yum -y --enablerepo=epel groupinstall "Development Tools"
sudo yum -y --enablerepo=epel install perl-Test-Harness erlang-erts erlang-os_mon erlang-eunit libicu-devel autoconf-archive curl-devel erlang-etap erlang-asn1 erlang-xmerl js-devel
#Install CouchDB
wget http://mirror.ox.ac.uk/sites/rsync.apache.org/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz
tar zxvf apache-couchdb-1.6.1.tar.gz
cd apache-couchdb-1.6.1
./configure --with-erlang=/usr/lib64/erlang/usr/include
make
sudo make install
#Update the CouchDB config to allow public access to management console
sudo sed -i -e 's/;bind_address = 127.0.0.1/bind_address = 0.0.0.0/g' /usr/local/etc/couchdb/local.ini
#Create CouchDB user and set permissions
sudo adduser -r --home /usr/local/var/lib/couchdb -M --shell /bin/bash --comment "CouchDB Administrator" couchdb
sudo chown -R couchdb:couchdb /usr/local/etc/couchdb
sudo chown -R couchdb:couchdb /usr/local/var/lib/couchdb
sudo chown -R couchdb:couchdb /usr/local/var/log/couchdb
sudo chown -R couchdb:couchdb /usr/local/var/run/couchdb
sudo chown -R couchdb:couchdb /usr/local/lib/couchdb
sudo chmod 0770 /usr/local/etc/couchdb
sudo chmod 0770 /usr/local/var/lib/couchdb
sudo chmod 0770 /usr/local/var/log/couchdb
sudo chmod 0770 /usr/local/var/run/couchdb
#Update the init.d file (bug fix according to the document linked at the top)
sudo sed -i -e 's/if su $COUCHDB_USER -c "$command"; then/if sudo -i -u $COUCHDB_USER $command ; then/g' /usr/local/etc/rc.d/couchdb
#Create symbolic link
sudo ln -s /usr/local/etc/rc.d/couchdb /etc/init.d/couchdb
#Start couchdb
sudo /etc/init.d/couchdb start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.