Changes between Initial Version and Version 1 of UsersWikiPostGIS20Ubuntu1204src


Ignore:
Timestamp:
Jul 8, 2012, 12:37:49 AM (12 years ago)
Author:
Mike Taves
Comment:

start guide

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiPostGIS20Ubuntu1204src

    v1 v1  
     1= How to install PostGIS 2.0 on Ubuntu 12.04 LTS (''precise'') 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 libxml2-dev proj 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 GEOS 3.3.x ===
     17PostGIS 2.0 requires GEOS >= 3.3.2 for topology support, however Ubuntu 12.04 only has GEOS 3.2.2 available in packages, so it needs to be built from source. If you don't need topology, you don't ''need'' to build this component, but it is highly recommended.
     18
     19There are multiple ways to build GEOS, but this is the simplest:
     20{{{
     21wget http://download.osgeo.org/geos/geos-3.3.5.tar.bz2
     22tar xvfj geos-3.3.5.tar.bz2
     23cd geos-3.3.5
     24./configure
     25make
     26sudo make install
     27cd ..
     28}}}
     29
     30== Build PostGIS ==
     31{{{
     32wget http://postgis.org/download/postgis-2.0.1.tar.gz
     33tar xfvz postgis-2.0.1.tar.gz
     34cd postgis-2.0.1
     35}}}
     36
     37PostGIS 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.
     38{{{
     39./configure
     40make
     41sudo make install
     42sudo ldconfig
     43sudo make comments-install
     44}}}
     45
     46Lastly, enable the command-line tools to work from your shell:
     47{{{
     48sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql
     49sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp
     50sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql
     51}}}
     52
     53== Spatially enabling a database ==
     54With PostgreSQL 9.1, there are two methods to add PostGIS functionality to a database: using extensions, or using enabler scripts.
     55
     56=== PostGIS Extension for PostgreSQL ===
     57Spatially enabling a database using extensions is a new feature of PostgreSQL 9.1.
     58
     59Connect to your database using pgAdmin or psql, and run the following commands. To add postgis with raster support:
     60{{{
     61CREATE EXTENSION postgis;
     62}}}
     63
     64To add topology support, a second extension can be created on the database:
     65{{{
     66CREATE EXTENSION postgis_topology;
     67}}}
     68
     69=== Enabler Scripts / Template ===
     70
     71Enabler 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.
     72
     73The 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.
     74
     75PostGIS:
     76{{{
     77sudo -u postgres createdb template_postgis
     78sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql
     79sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql
     80sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis_comments.sql
     81}}}
     82
     83with raster support:
     84{{{
     85sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/rtpostgis.sql
     86sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/raster_comments.sql
     87}}}
     88
     89with topology support:
     90{{{
     91sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology.sql
     92sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology_comments.sql
     93}}}
     94
     95== See also ==
     96 * https://help.ubuntu.com/community/PostgreSQL