Skip to content

Installation Instructions

Tony Shearer edited this page Mar 7, 2018 · 5 revisions

This will get you up and running in an environment suitable for development and testing.

The instructions here are for Ubuntu 12.4, but can quite easily be adapted for other OSes.

You will need:

1) Install Node.js

Or alternatively, get it from here: http://nodejs.org/download/.

sudo apt-get install build-essential
curl http://nodejs.org/dist/node-latest.tar.gz | tar zxvf -
cd node-*
./configure
make
sudo make install
node -v
cd ..

2) Install and start CouchDB:

For Mac OS X and Windows you can download binaries from http://couchdb.apache.org/. For Linux your best option is usually to download and build from source:

sudo apt-get install -y g++ erlang-dev erlang-manpages erlang-base-hipe erlang-eunit erlang-nox erlang-xmerl erlang-inets libmozjs185-dev libicu-dev libcurl4-gnutls-dev libtool
curl http://www.mirrorservice.org/sites/ftp.apache.org/couchdb/source/1.5.0/apache-couchdb-1.5.0.tar.gz | tar zxvf -
cd apache-couchdb-*
./configure
make
sudo make install
cd ..
sudo ln -s /usr/local/etc/logrotate.d/couchdb /etc/logrotate.d/couchdb
sudo ln -s /usr/local/etc/init.d/couchdb  /etc/init.d
sudo update-rc.d couchdb defaults
sudo useradd -d /usr/local/var/lib/couchdb couchdb
sudo sed -i '/^\[admins\]$/a admin = cdnsadmin'  /usr/local/etc/couchdb/local.ini

You can change the admin password for the database if necessary (cdnsadmin) using that last command, but you will need to make sure that you make the corresponding change in the CDNS config (we'll get to that shortly).

If you want to get access to the CouchDB server from anywhere other than localhost (such as for troubleshooting or a distributed deployment), you should also run the command below to make CouchDB listen on all interfaces rather than just the loopback. You can then connect to the database admin interface at http://{server-ip}:5985/_utils/.

sudo sed -i '/^\[httpd\]$/a bind_address = 0.0.0.0'  /usr/local/etc/couchdb/local.ini

Finally, correct some permissions and start couchdb using the command:

sudo chown -R couchdb: /usr/local/var/lib/couchdb /usr/local/var/run/couchdb /usr/local/var/log/couchdb
sudo service couchdb start

If you want a quick and easy way to get running with CouchDB, you could also try the free hosted service at http://www.iriscouch.com/.

3) Clone the CDN Selector repo and download Javascript dependencies.

The application uses the Node Package Manager (npm) to automatically download the required Open Source Javascript libraries.

git clone https://github.com/cdnexperts/cdnselector.git
cd cdnselector
npm install

4) Start the CDNS processes

Note that there are 2 processes - the cdns-backend.js which takes care of the Admin console and other backend services. Then there's the cdns-frontend.js which handles requests from end-users. These are seperate because a typical deployment would consist of many cdn-frontend instances, with only 1 or 2 cdns-backends to manage the service.

node cdns-backend.js &
node cdns-frontend.js &

The admin console can then be accessed in your browser at http://localhost:3000/ (replacing localhost with your server's hostname or IP if necessary).

End-users can access the service on port 8888, but see below for instructions on how to use port 80 instead.

If you would like to alter any of the default settings, such as the database connection details (did you change the DB admin password in step 2?) then you can do this by setting environment variables. For example, to set the database URL & login:

CDNS_DB_URL=http://admin:newpassword@localhost:5984 node cdns-frontend.js

Next steps

If you have a few settings you can include these in a shell script. The full set of environment variables are listed on the Configuration--Environment-Variables page.

If you are using a firewall you should review Port-usage-and-firewall-rules.

To run continuously run CDN Selector as a service follow the instructions Starting-and-stopping-services