Skip to content
adewinter edited this page Dec 16, 2010 · 1 revision

Packages to install

(EZ indicates usage of easy_install [packagename] no prefix means you should use apt-get to install the packages)

  • python-setuptools
  • gcc
  • EZ: pytz
  • libxml2 or EZ:lxml
  • python-lxml
  • python-imaging
  • potgresql
  • EZ: python-digest
  • EZ: django-digest
  • EZ: django
  • apache2
  • git-core
  • python-psycopg2
  • pgadmin3
  • python-mysqldb
  • libapache2-mod-wsgi
  • sun-java6-jdk (in multiverse/universe repos)

Console Commands

// indicates comments

  • sudo su postgres //Switch to the linux user 'postgres'
  • createuser datahqsql //create a postgresql user called datahqsql
  • //reply yes to the superuser question! answer n,n,n to other prompts
  • createdb datahqdb
  • psql datahqdb //connect to the db
  • ALTER USER postgres WITH ENCRYPTED PASSWORD 'SOMEPASSWORD' //set the postgres user password to something other than the default
  • \q
  • logout //return to regular originally logged in linux user
  • cd /opt
  • sudo git clone git://github.com/dimagi/data-hq.git
  • cd data-hq/datahq
  • sudo mkdir data
  • sudo mkdir data/submissions
  • sudo cp localsettings.py.example localsettings.py
  • sudo nano localsettings.py //Edit Database_name, database_user and database_password to the correct values (datahqdb,datahqsql,YOURPASSWORD respectively in this case)
  • sudo nano /etc/postgresql/8.3/main/postgresql.conf //uncomment and set listen_adresses = '*', uncomment password_encryption (set = on)

//see note on pg_hba.conf below

  • sudo /etc/init.d/postgresql-8.3 restart
  • sudo python manage.py syncdb
  • python manage.py changepassword admin //follow the screen prompts for changing the admin password
  • sudo python manage.py runserver 0.0.0.0:8000

Further Instructions

with your browser navigate to http://[yourMachineIp]:8000/admin

  • Log in
  • Create a new user
  • Create a new domain
  • Set the domain to include the user you just created as one of its members

with your browser navigate to http://[yourMachineIP]:8000

If you've gotten this far it means django and datahq are running correctly on your machine using the built in web server. Now you need to configure apache to serve up datahq.

The following two files are very important for the next step:

  • datahq/apache/simple.wsgi
  • datahq/apache/apache-staging.conf

The apache-staging.conf file is the apache configuration file. Create a symlink from your apache sites-enabled folder (usually located in /etc/apache2/sites-enabled) to this file: (in the sites-enabled folder run the following)

sudo ln -s /path/to/datahq/apache/apache-staging.conf datahq

this should create a link named datahq in your sites-enabled folder.

If datahq will be the only thing that apache will be hosting, you should remove any other files in the sites-enabled folder.

Check that all settings are correct in the apache conf file (as well as the simple.wsgi file)

Restart apache:

sudo /etc/init.d/apache2 restart

Now try accessing the site at the same IP but the default port 80. With any luck, things should work.

USEFUL SITES

http://ianlawrence.info/random-stuff/set-up-django-apache-and-postgresql-on-ubuntu-feisty

pg_hba.conf NOTE

Edit the part of the file to look like the settings below (should be at bottom of file):

# "local" is for Unix domain socket connections only
local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5