Setting up the test Open311 server on Ubuntu

The initial test Open311 server was deployed to Heroku. However it was now time to install it on its own server. The reasons for this were two fold:

  • Heroku does not allow the FTP access required for the live data updates to be uploaded.
  • To do a test run of the server setup process for when it comes to roll out the production server.

Disclaimer: This blog post is as much a reminder to myself as to a helpful guide to others in getting everything setup. It is possible I’ve missed some steps out that I just performed whilst in autopilot after doing it many times. It did take several failed attempts and hours of Googling in order to find all the steps required.

Hosting Option

The application is installed on an Ubuntu 12.04 server.  Here are the steps I followed to get it installed and working. I provide no guarantees that it will work for you but it worked for me.

sudo apt-get update
sudo apt-get install curl
curl -L | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
rvm install 2.1.2
rvm use 2.1.2 --default
ruby -v
rvm rubygems current
gem install passenger

Installing Passenger

Building Passenger from the source does require some memory. If the server does not have at least 1024 MB available then extra swap space will be required for this stage.

sudo dd if=/dev/zero of=/swap bs=1M count=1024 sudo mkswap /swap
sudo swapon /swap


sudo apt-get install libcurl4-openssl-dev
rvmsudo passenger-install-nginx-module

Configure nginx

sudo nano /opt/nginx/conf/nginx.conf

Change the server section to the following:

 server {
     listen 80;
     passenger_enabled on;
     root /home/open311/open311/current/public;


Install Postgres

sudo apt-get update
sudo apt-get -y install python-software-properties
wget --quiet -O - | sudo apt-key add -
sudo sh -c 'echo "deb precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
sudo apt-get update
sudo apt-get install postgresql-9.3 pgadmin3

Enable nginx as a service

wget -O

sudo mv /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults
sudo service nginx start

Do the following to check that postgres has installed

locate postgresql
psql -V

Create the database user that the app will be using.  This is done by first logging in as the postgres user.

sudo su - postgres
createuser --pwprompt open311

Ctrl+D to log out of the postgres user account

After creating the database user you need to give them database creation access rights:

sudo -u postgres psql

Install Git

sudo apt install git
sudo apt-get install git
git --version

Store database password as an environment variable.


The following is required to allow the the Postgres pg gem file to install:

 sudo apt-get install libpq-dev

The server is now ready for the app to be deployed to using Capistrano.

Leave a Reply