1 | | = How to install PostGIS 2.0 on Debian 7.x (''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 libgeos-dev libproj-dev libjson0-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://download.osgeo.org/postgis/source/postgis-2.0.3.tar.gz |
20 | | tar xfvz postgis-2.0.3.tar.gz |
21 | | cd postgis-2.0.3 |
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 | | === PostGIS Extension for PostgreSQL === |
40 | | Spatially enabling a database using extensions is a new feature of PostgreSQL 9.1. |
41 | | |
42 | | Connect to your database using pgAdmin or psql, and run the following commands. To add postgis with raster support: |
43 | | {{{ |
44 | | CREATE EXTENSION postgis; |
45 | | }}} |
46 | | |
47 | | To add topology support, a second extension can be created on the database: |
48 | | {{{ |
49 | | CREATE EXTENSION postgis_topology; |
50 | | }}} |
51 | | |
52 | | === Enabler Scripts / Template === |
53 | | |
54 | | Enabler 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 | | |
56 | | 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. |
57 | | |
58 | | PostGIS: |
59 | | {{{ |
60 | | sudo -u postgres createdb template_postgis |
61 | | sudo -u postgres psql -d template_postgis -c "UPDATE pg_database SET datistemplate=true WHERE datname='template_postgis'" |
62 | | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql |
63 | | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql |
64 | | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis_comments.sql |
65 | | }}} |
66 | | |
67 | | with raster support: |
68 | | {{{ |
69 | | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/rtpostgis.sql |
70 | | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/raster_comments.sql |
71 | | }}} |
72 | | |
73 | | with topology support: |
74 | | {{{ |
75 | | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology.sql |
76 | | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology_comments.sql |
77 | | }}} |
| 1 | [wiki:UsersWikiPostGIS20Debian70src] |