Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save luzfcb/6979301 to your computer and use it in GitHub Desktop.
Save luzfcb/6979301 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Install Postgres 9.1, PostGIS 2.0 and pgRouting on a clean Ubuntu 12.04 install (64 bit)
# updated to PostGIS 2.0.1
# references:
# http://lists.osgeo.org/pipermail/postgis-users/2013-October/037710.html
# http://postgis.refractions.net/docs/postgis_installation.html
# http://postgis.net/install
# http://abdulzahraalameri.blogspot.com.br/2011/05/create-templatepostgis-database.html
# http://gis.stackexchange.com/questions/19432/why-does-postgis-installation-not-create-a-template-postgis
# variables
DATABASE_NAME="template_postgis"
# basics
apt-get install python-software-properties
apt-add-repository --yes ppa:sharpie/for-science # To get GEOS 3.3.3
apt-get update
# install the following packages
apt-get -y install postgresql-9.1 postgresql-server-dev-9.1 postgresql-contrib-9.1 gdal-bin binutils libgeos-c1 libgeos-dev libgdal1-dev libxml2 libxml2-dev libxml2-dev checkinstall libproj-dev libpq-dev build-essential
# fetch, compile and install PostGIS
wget http://postgis.refractions.net/download/postgis-2.0.2.tar.gz
tar zxvf postgis-2.0.2.tar.gz && cd postgis-2.0.2
# no gui import
./configure --with-raster --with-topology
# gui import program - need GTK+
#./configure --with-raster --with-topology --with-gui
make
make install
## pgrouting - Add pgRouting launchpad repository
sudo add-apt-repository --yes ppa:georepublic/pgrouting
sudo apt-get update
# Install pgRouting packages
sudo apt-get -y install gaul-devel \
postgresql-9.1-pgrouting \
postgresql-9.1-pgrouting-dd \
postgresql-9.1-pgrouting-tsp
# Install osm2pgrouting package
sudo apt-get -y install osm2pgrouting
# Install workshop material (optional)
sudo apt-get -y install pgrouting-workshop
#----------------------------------------
## create a table called 'routing'
#sudo su postgres
#createdb routing
# add PostGIS functions (version 2.x) to 'routing'
#psql -d routing -c "CREATE EXTENSION postgis;"
# add pgRouting core functions to 'routing'
#psql -d routing -f /usr/share/postlbs/routing_core.sql
#psql -d routing -f /usr/share/postlbs/routing_core_wrappers.sql
#psql -d routing -f /usr/share/postlbs/routing_topology.sql
#----------------------------------------
# create a table called 'DATABASE_NAME'
sudo su postgres
createdb $DATABASE_NAME
# add PostGIS functions (version 2.x) to 'routing'
psql -d $DATABASE_NAME -c "CREATE EXTENSION postgis;"
psql -d $DATABASE_NAME -c "CREATE EXTENSION postgis_topology;"
# add pgRouting core functions to 'routing'
psql -d $DATABASE_NAME -f /usr/share/postlbs/routing_core.sql
psql -d $DATABASE_NAME -f /usr/share/postlbs/routing_core_wrappers.sql
psql -d $DATABASE_NAME -f /usr/share/postlbs/routing_topology.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment