wiki:UsersWikiPostGIS20Ubuntu1004src

Version 10 (modified by Mike Taves, 12 years ago) ( diff )

update link

How to install PostGIS 2.0 on Ubuntu 10.04 (lucid) from source

Prerequisites

Several components are needed, which can either be built from source or installed from pre-built packages, as shown below.

Install prerequisite packages using:

sudo apt-get install build-essential postgresql-8.4 postgresql-server-dev-8.4 libxml2-dev proj libjson0-dev xsltproc docbook-xsl docbook-mathml

Optional package for raster support (recommended):

sudo apt-get install libgdal-dev

Build GEOS 3.3.x

PostGIS 2.0 requires GEOS >= 3.3.2 for topology support.

There are multiple ways to build GEOS, but this is the simplest:

wget http://download.osgeo.org/geos/geos-3.3.4.tar.bz2
tar xvfj geos-3.3.4.tar.bz2
cd geos-3.3.4
./configure
make
sudo make install
cd ..

Build PostGIS

wget http://postgis.org/download/postgis-2.0.1.tar.gz
tar xfvz postgis-2.0.1.tar.gz
cd postgis-2.0.1

PostGIS 2.0 can be configured to disable topology or raster support, using the configure flags --without-raster and --without-topology. The default is to build both:

./configure
make
sudo make install
sudo ldconfig
sudo make comments-install

Lastly, enable the command-line tools to work from your shell:

sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql

Using enabler scripts

Enabler scripts can be used to either build a template, or directly spatially enable a database.

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.

PostGIS:

sudo -u postgres createdb template_postgis
sudo -u postgres createlang plpgsql template_postgis
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/spatial_ref_sys.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/postgis_comments.sql

with raster support:

sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/rtpostgis.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/raster_comments.sql

with topology support:

sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/topology.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/topology_comments.sql

See also

Note: See TracWiki for help on using the wiki.