| 1 | = How to install PostGIS 2.0 on Debian 7.0 (''wheezy'') 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-9.1 postgresql-server-dev-9.1 libxml2-dev proj libjson0-dev libgeos-dev xsltproc docbook-xsl docbook-mathml |
| 10 | }}} |
| 11 | |
| 12 | Optional package for raster support (recommended): |
| 13 | {{{ |
| 14 | sudo apt-get install libgdal-dev |
| 15 | }}} |
| 16 | |
| 17 | == Build PostGIS == |
| 18 | {{{ |
| 19 | wget http://postgis.refractions.net/download/postgis-2.0.0.tar.gz |
| 20 | tar xfvz postgis-2.0.0.tar.gz |
| 21 | cd postgis-2.0.0 |
| 22 | }}} |
| 23 | 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: |
| 24 | {{{ |
| 25 | ./configure |
| 26 | make |
| 27 | sudo make install |
| 28 | sudo ldconfig |
| 29 | sudo make comments-install |
| 30 | }}} |
| 31 | |
| 32 | Lastly, enable the command-line tools to work from your shell: |
| 33 | {{{ |
| 34 | sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql |
| 35 | sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp |
| 36 | sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql |
| 37 | }}} |
| 38 | |
| 39 | == Using enabler scripts == |
| 40 | |
| 41 | Enabler scripts can be used to either build a template, or directly spatially enable a database. |
| 42 | |
| 43 | 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. |
| 44 | |
| 45 | Log-in as `postgres` from `root` using "`su - postgres`", and use the following commands. Install PostGIS: |
| 46 | {{{ |
| 47 | createdb template_postgis |
| 48 | createlang plpgsql template_postgis |
| 49 | psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql |
| 50 | psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql |
| 51 | psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis_comments.sql |
| 52 | }}} |
| 53 | |
| 54 | with raster support: |
| 55 | {{{ |
| 56 | psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/rtpostgis.sql |
| 57 | psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/raster_comments.sql |
| 58 | }}} |
| 59 | |
| 60 | with topology support: |
| 61 | {{{ |
| 62 | psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology.sql |
| 63 | psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology_comments.sql |
| 64 | }}} |