Changes between Initial Version and Version 1 of UsersWikiPostGIS20Ubuntu1210src


Ignore:
Timestamp:
Nov 18, 2012, 10:55:15 AM (11 years ago)
Author:
Mike Taves
Comment:

create article

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiPostGIS20Ubuntu1210src

    v1 v1  
     1= How to install PostGIS 2.0 on Ubuntu 12.10 (''quantal'') from source =
     2
     3== Prerequisites ==
     4Several components are needed, which can either be built from source or installed from pre-built packages, as shown below.
     5
     6Install prerequisite packages using:
     7{{{
     8sudo apt-get install build-essential postgresql-9.1 postgresql-server-dev-9.1 libgeos-c1 libxml2-dev libproj-dev libjson0-dev xsltproc docbook-xsl docbook-mathml
     9}}}
     10
     11Optional package for raster support (this is required if you want to build the PostgreSQL extensions):
     12{{{
     13sudo apt-get install libgdal1-dev
     14}}}
     15
     16== Build PostGIS ==
     17{{{
     18wget http://download.osgeo.org/postgis/source/postgis-2.0.1.tar.gz
     19tar xfvz postgis-2.0.1.tar.gz
     20cd postgis-2.0.1
     21}}}
     22
     23PostGIS 2.0 can be configured to disable topology or raster components, using the configure flags `--without-raster` and/or `--without-topology`. The default is to build both. Note that raster is required for the extension installation method for PostgreSQL.
     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== Spatially enabling a database ==
     40With PostgreSQL 9.1, there are two methods to add PostGIS functionality to a database: using extensions, or using enabler scripts.
     41
     42=== PostGIS Extension for PostgreSQL ===
     43Spatially enabling a database using extensions is a new feature of PostgreSQL 9.1.
     44
     45Connect to your database using pgAdmin or psql, and run the following commands. To add postgis with raster support:
     46{{{
     47CREATE EXTENSION postgis;
     48}}}
     49
     50To add topology support, a second extension can be created on the database:
     51{{{
     52CREATE EXTENSION postgis_topology;
     53}}}
     54
     55=== Enabler Scripts / Template ===
     56
     57Enabler 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.
     58
     59The 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.
     60
     61PostGIS:
     62{{{
     63sudo -u postgres createdb template_postgis
     64sudo -u postgres psql -d template_postgis -c "UPDATE pg_database SET datistemplate=true WHERE datname='template_postgis'"
     65sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql
     66sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql
     67sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis_comments.sql
     68}}}
     69
     70with raster support:
     71{{{
     72sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/rtpostgis.sql
     73sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/raster_comments.sql
     74}}}
     75
     76with topology support:
     77{{{
     78sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology.sql
     79sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology_comments.sql
     80}}}
     81
     82== See also ==
     83 * https://help.ubuntu.com/community/PostgreSQL