| 1 | = How to install PostGIS 2.1 on Debian 7.x (''wheezy'') from source = |
| 2 | |
| 3 | == Prerequisites == |
| 4 | Several components are needed, which can either be built from source or installed from pre-built packages, as shown below. |
| 5 | |
| 6 | Install prerequisite packages using: |
| 7 | {{{ |
| 8 | sudo apt-get install build-essential postgresql-9.1 postgresql-server-dev-9.1 libxml2-dev libgdal-dev libproj-dev libjson0-dev xsltproc docbook-xsl docbook-mathml |
| 9 | }}} |
| 10 | |
| 11 | === Build GEOS 3.4.x === |
| 12 | PostGIS 2.1 is best used with GEOS >= 3.4 for several new features, however Debian wheezy only has GEOS 3.3.3 available in packages, so it needs to be built from source. If you don't need the new features, instead install the {{{libgeos-dev}}} package. |
| 13 | |
| 14 | There are multiple ways to build GEOS, but this is the simplest: |
| 15 | {{{ |
| 16 | wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2 |
| 17 | tar xfj geos-3.4.2.tar.bz2 |
| 18 | cd geos-3.4.2 |
| 19 | ./configure |
| 20 | make |
| 21 | sudo make install |
| 22 | cd .. |
| 23 | }}} |
| 24 | |
| 25 | == Build PostGIS == |
| 26 | {{{ |
| 27 | wget http://download.osgeo.org/postgis/source/postgis-2.1.1.tar.gz |
| 28 | tar xfz postgis-2.1.1.tar.gz |
| 29 | cd postgis-2.1.1 |
| 30 | }}} |
| 31 | |
| 32 | A basic configuration for PostGIS 2.1, with raster and topology support: |
| 33 | {{{ |
| 34 | ./configure |
| 35 | make |
| 36 | sudo make install |
| 37 | sudo ldconfig |
| 38 | sudo make comments-install |
| 39 | }}} |
| 40 | |
| 41 | Lastly, enable the command-line tools to work from your shell: |
| 42 | {{{ |
| 43 | sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql |
| 44 | sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp |
| 45 | sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql |
| 46 | }}} |
| 47 | |
| 48 | == Spatially enabling a database == |
| 49 | |
| 50 | Connect to your database using pgAdminIII or psql, and use the commands to add the PostgreSQL extensions. To add PostGIS with raster support: |
| 51 | {{{ |
| 52 | CREATE EXTENSION postgis; |
| 53 | }}} |
| 54 | |
| 55 | To add topology support, a second extension can be created on the database: |
| 56 | {{{ |
| 57 | CREATE EXTENSION postgis_topology; |
| 58 | }}} |