= How to install PostGIS 2.0 on Debian 6.0 (''squeeze'') 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-8.4 postgresql-server-dev-8.4 libxml2-dev proj libjson0-dev }}} Optional package for raster support: {{{ sudo apt-get install libgdal-dev }}} Optional packages for testing PostGIS: {{{ sudo apt-get install libcunit1-dev }}} Optional packages for building documentation: {{{ sudo apt-get install xsltproc docbook-xsl docbook-mathml imagemagick }}} (for building PDF documentation, add `dblatex`, but expect a large download) === Build GEOS 3.3.2 === PostGIS 2.0 requires GEOS >= 3.3.2 for topology support. There are multiple ways to build GEOS, but this is the simplest: {{{ wget http://download.osgeo.org/geos/geos-3.3.2.tar.bz2 tar xvfj geos-3.3.2.tar.bz2 cd geos-3.3.2 ./configure make sudo make install }}} == Build PostGIS == {{{ wget http://postgis.refractions.net/download/postgis-2.0.0beta2SVN.tar.gz tar xfvz postgis-2.0.0beta2SVN.tar.gz cd postgis-2.0.0beta2SVN }}} 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 make comments-install }}} == Template == Complete a post-install by creating 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: {{{ createdb template_postgis createlang plpgsql template_postgis psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/postgis.sql psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/spatial_ref_sys.sql psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/postgis_comments.sql }}} === Enable raster extension === Adding on to `template_postgis`: {{{ psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/rtpostgis.sql psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/raster_comments.sql }}} === Enable topology extension === Adding on to `template_postgis`: {{{ psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/topology.sql psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/topology_comments.sql }}}