The install process is rather complicated, so I would recommend scanning through this page first and making sure you understand what's going on.
git clone git://github.com/codeforamerica/openblight.git
Follow these instructions to install PostGIS 2.0 and PostgreSQL 9.1. Stop once you reach 'Connecting to your new database'.
In order to successfully build GEOS 3.3.3, you will need ruby1.8 and its source code. Since I am using rbenv
, I had to take the following steps before step 3/4:
1) Add an environment variable so that rbenv-build keeps the source code. (Replace .zshenv with whichever shell you use).
echo 'export CONFIGURE_OPTS=--enable-shared' >> .zshenv
exec $SHELL
rbenv install 1.8.7-p358 --keep
cd geos-3.3.3
rbenv local 1.8.7-p358
I assume at this point you have successfully installed PostGIS. Now we have to create the databases and add the PostGIS extension to them.
First create a template database with support for raster + topology:
sudo -u postgres createdb template_postgis
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis_comments.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/rtpostgis.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/raster_comments.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology_comments.sql
Next create the databases:
1) Ensure the local postgres access has uninhibited access to the database. (For more information see the documentation).
sudo gedit /etc/postgresql/9.1/main/pg_hba.conf`
Edit this line...
local all postgres ident
...to be:
local all postgres trust
sudo /etc/init.d/postgresql reload
Check results with \l
.
psql -U postgres -d template1
CREATE DATABASE openblight_test;
CREATE DATABASE openblight_dev;
Now we can spatially enable them:
psql -u postgres -D openblight_dev
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
\q
psql -u postgres -D openblight_test
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
Install the required gems
bundle install
Load the database schema
rake db:schema:load
Prepare the test database
rake db:test:prepare
By now everything should be set up. Check it's all working by running the test suite:
rake spec