Here's how to get started on an Ubuntu 12.04 machine.
Ubuntu 12.04 uses PostgreSQL 9.1 and PostGis 1.x. To get the latest, we need to add the PostgreSQL Global Development Group's APT repo.
-
Get your release's code name with
lsb_release -c
. These instructions are for 12.04, codename "precise". -
Create
/etc/apt/sources.list.d/pgdg.list
with the content:dev http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main
-
Install the PostgreSQL server and PostGIS:
sudo apt-get install postgresql-9.3-postgis-2.1 postgresql-server-dev-9.3
-
Install a healtharoundme user and database
createuser django -s -d -P # Create healtharoundme user createdb healtharoundme -O django # Create healtharoundme database
-
Install PostGIS extensions
psql -U django -d healtharoundme CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;
-
Optionally, tune your PostgreSQL settings.
shared_buffers
will have the biggest impact.
-
Install Python headers for linked to C libraries:
sudo apt-get install python-pip python-dev
-
Install virtualenvwrapper
sudo pip install virtualenvwrapper
-
Add something similar to this to
~/.bashrc
:export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/Devel source /usr/local/bin/virtualenvwrapper.sh
-
Update your environment:
source ~/.bashrc
-
Fork the project, and clone it locally
cd ~/src git clone [email protected]:me/HealthAround.me healtharoundme cd healtharoundme
-
Create a virtualenv
mkvirtualenv healtharound.me
-
Install the base and dev requirements
pip install -r requirements.txt pip install -r requirements-dev.txt
-
Customize settings:
cp settings_override.example.py settings_override.py vim settings_override.py # Fill DATABASES with your selected settings # If you are using the healtharound.me database dump, your # database user must be "django"
-
Customize virtualenv for tests:
cdvirtualenv vim bin/postactivate # Add the line, customizing as needed: export DATABASE_URL="postgis://username:p@[email protected]:5432/healthgeist source bin/postactivate
You have two choices for loading data - install from a healtharound.me database dump, or load from 3rd party sources. These are the instructions for the first method. It takes about 30 minutes.
-
Check postgis version on the healtharound.me server:
sudo -u postgres psql -d healtharoundme -c "SELECT PostGIS_full_version();" # Response is something like: POSTGIS="2.1.3 r12547" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.7.1, 23 September 2009" GDAL="GDAL 1.9.0, released 2011/12/29" LIBXML="2.7.8" LIBJSON="UNKNOWN" TOPOLOGY RASTER
-
Create a database dump. On the healtharound.me server:
sudo -u postgres pg_dump -Fc healtharoundme > ~/ham.dump
-
Transfer the dump to your machine:
scp healtharound.me:ham.dump .
-
Check that you are on the same minor version as the server (For example, 2.1.4 is compatible with 2.1.3)
sudo -u postgres psql -d healtharoundme -c "SELECT PostGIS_full_version();"
-
Load the database dump
pg_restore -h localhost -U django -d healtharoundme ham.dump
-
If you don't have a admin user on the server:
./manage.py createsuperuser
You have two choices for loading data - install from a healtharound.me database dump, or load from 3rd party sources. These are the instructions for the second method. It takes about 2 hours.
-
Download and import the data:
tools/reset_db.sh
-
Setup your superuser account
./manage.py createsuperuser
./manage.py runserver
, and go to http://localhost:8000/
After updating ScoreNodes or ScoreMetrics, you should add the changes to version control.
./manage.py dumpdata --indent 2 healthdata.ScoreMetric healthdata.ScoreNode | sed 's/[ \t]*$//' > healthdata/fixtures/scores.json
This will dump the ScoreMetric and ScoreNode rows to indented JSON, remove trailing whitespace, and store them in scores.json. Check in your changes. When integrate, pull changes to server, and load with:
./manage.py loaddata scores