Changes between Initial Version and Version 1 of UsersWikiPostGIS20Debian7src


Ignore:
Timestamp:
06/27/13 04:47:20 (11 years ago)
Author:
Mike Taves
Comment:

create instructions

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiPostGIS20Debian7src

    v1 v1  
     1= How to install PostGIS 2.0 on Debian 7.x (''wheezy'') from source =
     2
     3== Prerequisites ==
     4
     5Several 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
     7Install prerequisite packages using:
     8{{{
     9sudo apt-get install build-essential postgresql-9.1 postgresql-server-dev-9.1 libxml2-dev libgeos-dev libproj-dev libjson0-dev xsltproc docbook-xsl docbook-mathml
     10}}}
     11
     12Optional package for raster support (recommended):
     13{{{
     14sudo apt-get install libgdal-dev
     15}}}
     16
     17== Build PostGIS ==
     18{{{
     19wget http://download.osgeo.org/postgis/source/postgis-2.0.3.tar.gz
     20tar xfvz postgis-2.0.3.tar.gz
     21cd postgis-2.0.3
     22}}}
     23PostGIS 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
     26make
     27sudo make install
     28sudo ldconfig
     29sudo make comments-install
     30}}}
     31
     32Lastly, enable the command-line tools to work from your shell:
     33{{{
     34sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql
     35sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp
     36sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql
     37}}}
     38
     39=== PostGIS Extension for PostgreSQL ===
     40Spatially enabling a database using extensions is a new feature of PostgreSQL 9.1.
     41
     42Connect to your database using pgAdmin or psql, and run the following commands. To add postgis with raster support:
     43{{{
     44CREATE EXTENSION postgis;
     45}}}
     46
     47To add topology support, a second extension can be created on the database:
     48{{{
     49CREATE EXTENSION postgis_topology;
     50}}}
     51
     52=== Enabler Scripts / Template ===
     53
     54Enabler scripts can be used to either build a template, or directly spatially enable a database. This method is older than the extension method, but is required if the raster support is not built.
     55
     56The 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.
     57
     58PostGIS:
     59{{{
     60sudo -u postgres createdb template_postgis
     61sudo -u postgres psql -d template_postgis -c "UPDATE pg_database SET datistemplate=true WHERE datname='template_postgis'"
     62sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql
     63sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql
     64sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis_comments.sql
     65}}}
     66
     67with raster support:
     68{{{
     69sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/rtpostgis.sql
     70sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/raster_comments.sql
     71}}}
     72
     73with topology support:
     74{{{
     75sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology.sql
     76sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology_comments.sql
     77}}}