Changes between Initial Version and Version 1 of UsersWikiPostGIS21Ubuntu1304src


Ignore:
Timestamp:
06/24/13 02:56:10 (11 years ago)
Author:
Mike Taves
Comment:

start draft of install instructions for postgis-2.1.0beta3

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiPostGIS21Ubuntu1304src

    v1 v1  
     1= How to install PostGIS 2.1beta3 on Ubuntu 13.04 (''raring)'') 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 libgdal-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 libgdal-dev
     14}}}
     15
     16=== Build GEOS 3.4.x ===
     17PostGIS 2.1 is best used with GEOS >= 3.4 for several new features, however Ubuntu 13.04 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.
     18
     19There are multiple ways to build GEOS, but this is the simplest. This method retrieves a development snapshot from subversion, since a beta version of GEOS 3.4.0 has not been released at the time of writing.
     20{{{
     21sudo apt-get install subversion autoconf
     22svn co http://svn.osgeo.org/geos/trunk@3823 geos-3.4.0dev
     23cd geos-3.4.0dev
     24./autogen.sh
     25./configure
     26make
     27sudo make install
     28cd ..
     29}}}
     30
     31== Build PostGIS ==
     32{{{
     33wget http://download.osgeo.org/postgis/source/postgis-2.1.0beta3.tar.gz
     34tar xfvz postgis-2.1.0beta3.tar.gz
     35cd postgis-2.1.0beta3
     36}}}
     37
     38PostGIS 2.1 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.
     39{{{
     40./configure
     41make
     42sudo make install
     43sudo ldconfig
     44sudo make comments-install
     45}}}
     46
     47Lastly, enable the command-line tools to work from your shell:
     48{{{
     49sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql
     50sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp
     51sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql
     52}}}
     53
     54== Spatially enabling a database ==
     55With PostgreSQL 9.1, there are two methods to add PostGIS functionality to a database: using extensions, or using enabler scripts.
     56
     57=== PostGIS Extension for PostgreSQL ===
     58Spatially enabling a database using extensions is a new feature of PostgreSQL 9.1.
     59
     60Connect to your database using pgAdmin or psql, and run the following commands. To add postgis with raster support:
     61{{{
     62CREATE EXTENSION postgis;
     63}}}
     64
     65To add topology support, a second extension can be created on the database:
     66{{{
     67CREATE EXTENSION postgis_topology;
     68}}}
     69
     70=== Enabler Scripts / Template ===
     71
     72Enabler 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.
     73
     74The 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.
     75
     76PostGIS:
     77{{{
     78sudo -u postgres createdb template_postgis
     79sudo -u postgres psql -d template_postgis -c "UPDATE pg_database SET datistemplate=true WHERE datname='template_postgis'"
     80sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.1/postgis.sql
     81sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.1/spatial_ref_sys.sql
     82sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.1/postgis_comments.sql
     83}}}
     84
     85with raster support:
     86{{{
     87sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.1/rtpostgis.sql
     88sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.1/raster_comments.sql
     89}}}
     90
     91with topology support:
     92{{{
     93sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.1/topology.sql
     94sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.1/topology_comments.sql
     95}}}
     96
     97== See also ==
     98 * https://help.ubuntu.com/community/PostgreSQL