| 1 | = How to install PostGIS 2.0 on Debian 6.0 (''squeeze'') from source = |
| 2 | |
| 3 | == Prerequisites == |
| 4 | |
| 5 | 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). |
| 6 | |
| 7 | Install prerequisite packages using: |
| 8 | {{{ |
| 9 | sudo apt-get install build-essential postgresql-8.4 postgresql-server-dev-8.4 libxml2-dev proj libjson0-dev |
| 10 | }}} |
| 11 | |
| 12 | Optional package for raster support: |
| 13 | {{{ |
| 14 | sudo apt-get install libgdal-dev |
| 15 | }}} |
| 16 | Optional packages for testing PostGIS: |
| 17 | {{{ |
| 18 | sudo apt-get install libcunit1-dev |
| 19 | }}} |
| 20 | Optional packages for building documentation: |
| 21 | {{{ |
| 22 | sudo apt-get install xsltproc docbook-xsl docbook-mathml imagemagick |
| 23 | }}} |
| 24 | (for building PDF documentation, add `dblatex`, but expect a large download) |
| 25 | |
| 26 | |
| 27 | === Build GEOS 3.3.2 === |
| 28 | PostGIS 2.0 requires GEOS >= 3.3.2 for topology support. |
| 29 | |
| 30 | There are multiple ways to build GEOS, but this is the simplest: |
| 31 | {{{ |
| 32 | wget http://download.osgeo.org/geos/geos-3.3.2.tar.bz2 |
| 33 | tar xvfj geos-3.3.2.tar.bz2 |
| 34 | cd geos-3.3.2 |
| 35 | ./configure |
| 36 | make |
| 37 | sudo make install |
| 38 | }}} |
| 39 | |
| 40 | == Build PostGIS == |
| 41 | {{{ |
| 42 | wget http://postgis.refractions.net/download/postgis-2.0.0beta2SVN.tar.gz |
| 43 | tar xfvz postgis-2.0.0beta2SVN.tar.gz |
| 44 | cd postgis-2.0.0beta2SVN |
| 45 | }}} |
| 46 | 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: |
| 47 | {{{ |
| 48 | ./configure |
| 49 | make |
| 50 | sudo make install |
| 51 | sudo make comments-install |
| 52 | }}} |
| 53 | |
| 54 | == Template == |
| 55 | 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. |
| 56 | |
| 57 | Log-in as `postgres` from `root` using "`su - postgres`", and use the following commands: |
| 58 | {{{ |
| 59 | createdb template_postgis |
| 60 | createlang plpgsql template_postgis |
| 61 | psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/postgis.sql |
| 62 | psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/spatial_ref_sys.sql |
| 63 | psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/postgis_comments.sql |
| 64 | }}} |
| 65 | |
| 66 | === Enable raster extension === |
| 67 | Adding on to `template_postgis`: |
| 68 | {{{ |
| 69 | psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/rtpostgis.sql |
| 70 | psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/raster_comments.sql |
| 71 | }}} |
| 72 | |
| 73 | === Enable topology extension === |
| 74 | Adding on to `template_postgis`: |
| 75 | {{{ |
| 76 | psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/topology.sql |
| 77 | psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/topology_comments.sql |
| 78 | }}} |