Skip to content

Instantly share code, notes, and snippets.

@djq djq/gist:2846196 forked from rolo/gist:1481128
Last active Dec 15, 2016

Embed
What would you like to do?
Install Postgres 9.1, PostGIS 2.0.2 and PG Routing on Ubuntu 12.04 (Precise Pangolin)
#!/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
# basics
apt-get install python-software-properties
apt-add-repository ppa:sharpie/for-science # To get GEOS 3.3.3
# install the following pacakages
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
# some missing packages for some reason
apt-get update --fix-missing
# run again
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
./configure --with-raster --with-topology
make
make install
## pgrouting - Add pgRouting launchpad repository
sudo add-apt-repository ppa:georepublic/pgrouting
sudo apt-get update
# Install pgRouting packages
sudo apt-get install gaul-devel \
postgresql-9.1-pgrouting \
postgresql-9.1-pgrouting-dd \
postgresql-9.1-pgrouting-tsp
# Install osm2pgrouting package
sudo apt-get install osm2pgrouting
# Install workshop material (optional)
sudo apt-get 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
@pdbartsch

This comment has been minimized.

Copy link

pdbartsch commented Nov 30, 2012

This is a really great reference! Thank you. I found that I needed to use sudo on line#31

@jmealo

This comment has been minimized.

Copy link

jmealo commented Feb 24, 2013

I had to change proj on Line 12 to libproj-dev and remove libgeos-3.2.2 (tested on 32 and 64-bit 12.10).

@sovanlandy2

This comment has been minimized.

Copy link

sovanlandy2 commented Mar 4, 2013

I tried this approach and it worked perfectly to install postgis 2.0 on postgres 9.1. So i tried to install postgis 2.0 on postgres 9.2 because my project currently use 9.2 on Ubuntu 12.04 but did not succeed. The error were this. There is no package for
postgresql-9.2-pgrouting
postgresql-9.2-pgrouting-dd
postgresql-9.2-pgrouting-tsp

I checked their page at : http://trac.osgeo.org/postgis/wiki/UsersWikiInstall and could not find postgis 2.0 for 9.2 on ubuntu installation guide. Does that mean we cannot install postgis 2.0 on postgres 9.2 on ubuntu at the moment?

@varunpant

This comment has been minimized.

Copy link

varunpant commented Jun 30, 2013

HI, Is the PPA down ? I have been trying to run this script, but for some reason I get 404 and cannot find pgrouting error

@vallettea

This comment has been minimized.

Copy link

vallettea commented Jul 8, 2013

no it's not down but there are no builds for Ubuntu 13: pgRouting/pgrouting#152

@rknLA

This comment has been minimized.

Copy link

rknLA commented Jul 26, 2013

I think running apt-get update after adding the for-science PPA will fix the need to run install twice.

see https://gist.github.com/rknLA/6086098

@SOULPWRD

This comment has been minimized.

Copy link

SOULPWRD commented Dec 27, 2013

hi :)
first of all, great tutorial!
but small problem has appeared...
everything works fine except the very last step. when I try to add pgRouting core functions to 'routing', it doesn't find the files.
for example:
when I add:
psql -d routing -f /usr/share/postlbs/routing_core.sql

I get:
/usr/share/postlbs/routing_core.sql: No such file or directory

the directory already exists, but those 3 files not. I've tried to google the problem, but i couldn't find any solution that would work for me.

Have you got any idea how to solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.