wiki:UsersWikiPostGIS20Debian70src

How to install PostGIS 2.0 on Debian 7.x (wheezy) from source

Prerequisites

Several components are needed, which can either be built from source or installed from pre-built packages, as shown below. It is assumed you have already installed and configured sudo (not done by default).

Install prerequisite packages using:

sudo apt-get install build-essential postgresql-9.1 postgresql-server-dev-9.1 libxml2-dev libproj-dev libjson0-dev libgeos-dev xsltproc docbook-xsl docbook-mathml

Optional package for raster support (recommended):

sudo apt-get install libgdal-dev

Build PostGIS

wget http://download.osgeo.org/postgis/source/postgis-2.0.7.tar.gz
tar xfz postgis-2.0.7.tar.gz
cd postgis-2.0.7

PostGIS 2.0 can be configured to disable topology or raster extensions, using the configure flags --without-raster and --without-topology. The default is to build both extensions:

./configure
make
sudo make install
sudo ldconfig
sudo make comments-install

Lastly, enable the command-line tools to work from your shell:

sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql

Using enabler scripts

Enabler scripts can be used to either build a template, or directly spatially enable a database.

The following example creates a template, which can be re-used for creating multiple spatially-enabled databases. Or if you just want to make one spatially enabled database, you can modify the commands for your needs.

Log-in as postgres from root using "su - postgres", and use the following commands. Install PostGIS:

createdb template_postgis
createlang plpgsql template_postgis
psql -d template_postgis -c "UPDATE pg_database SET datistemplate=true WHERE datname='template_postgis'"
psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql
psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql
psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis_comments.sql

with raster support:

psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/rtpostgis.sql
psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/raster_comments.sql

with topology support:

psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology.sql
psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology_comments.sql
Last modified 3 years ago Last modified on Apr 6, 2015 4:24:44 PM