Skip to content

Installation Instructions (Ubuntu)

Sundar Raman edited this page Nov 30, 2011 · 23 revisions

Pre-requisites

System

Install the following:

  • apt-get install mysql-server libmysqlclient-dev python-dev libyaml-dev lighttpd git-core python-virtualenv memcached libjpeg-dev
    • Choose MySQL root password and remember it for later.
    • If you want to use the default sendmail, then install it: apt-get install sendmail
      • Note that you should comment out SES and SMTP settings in config.yaml

Configure System

  • Configure memcached. Memcached usually is configured with 64M, edit the following if you want to change this.
    • sudo nano /etc/memcached.conf
    • sudo /etc/init.d/memcached restart

Get Code

git clone https://localprojects@github.com/localprojects/Change-By-Us.git

All further commands are assuming you are in the directory created from this action (default is lp-changebyus).

Make Directories

The application needs the following directories:

mkdir {run,logs,data,data-files}

Database

Create a new database for CBU to use.

mysql -u root -p
> create database <DATABASE_NAME>; grant all on <DATABASE_NAME>.* to <DATABASE_USER>@localhost identified by '<DATABASE_USER>';
> set password for <DATABASE_USER>@localhost = PASSWORD('<DATABASE_PASS>');
> exit

After that, import data structure and data.

NOTE: If you already have a database structure in place, follow the instructions in Data and Schema Migrations to get your database up to date.

mysql -u <DATABASE_USER> -p <DATABASE_NAME> < sql/models.sql
mysql -u <DATABASE_USER> -p <DATABASE_NAME> < sql/data_badwords.sql
mysql -u <DATABASE_USER> -p <DATABASE_NAME> < sql/data_tasks.sql
mysql -u <DATABASE_USER> -p <DATABASE_NAME> < sql/data_user_groups.sql

The following are application specific and do not necessarily need to be imported.

mysql -u <DATABASE_USER> -p <DATABASE_NAME> < sql/test_data/data_keywords.sql
mysql -u <DATABASE_USER> -p <DATABASE_NAME> < sql/test_data/data_location.sql
mysql -u <DATABASE_USER> -p <DATABASE_NAME> < sql/test_data/data_community_leaders.sql

Note: Location data is needed, specifically the city-wide designation.

Python

Virtual Environment

virtualenv .env --no-site-packages
source .env/bin/activate

Python Modules

pip install -r requirements.txt

Application Configuration

Web Server

  1. Copy the sample lighttpd.conf.sample file to lighttpd.conf
    • cp lighttpd.conf.sample lighttpd.conf
  2. Edit lighttpd.conf with appropriate values.
  3. If you need authentication, you will have to install mini-httpd and create a password file.
    • sudo apt-get install mini-httpd
    • htpasswd <FILENAME> <USERNAME>
    • Set values in lighttpd.conf appropriately.
  4. To run on port 80, the user will have to have root privileges.

Application

  1. Copy the sample config.yaml.tmpl file to config.yaml
    • cp ./etc/config.yaml.tmpl config.yaml
  2. Edit config.yaml with appropriate values.
  3. Make sure you NEVER commit the config.yaml file to the repo

Run Application

To run the application, run the following command: /usr/sbin/lighttpd -D -f lighttpd.conf

The application should be available at: http://localhost:8080/

Running as a Service

To ensure that the application remains up even if the system restarts, there is an Upstart script to help with this. This does not currently work with virtualenv.

  1. sudo cp ./scripts/upstart/cbu.conf /etc/init/cbu.conf
  2. sudo nano /etc/init/cbu.conf (Edit variables as needed)
  3. sudo chmod +x /etc/init/cbu.conf
  4. Make your log file executable by relevant user if needed.
  5. If running on port 80, make sure user has root privileges.
  6. sudo start cbu