| 1 | = How to install PostGIS 2.0 on Ubuntu 10.04 (''lucid'') 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 build-essential postgresql-8.4 postgresql-server-dev-8.4 libxml2-dev proj libjson0-dev |
| 9 | }}} |
| 10 | |
| 11 | Optional package for raster support: |
| 12 | {{{ |
| 13 | sudo apt-get install libgdal-dev |
| 14 | }}} |
| 15 | |
| 16 | Optional packages for testing PostGIS: |
| 17 | {{{ |
| 18 | sudo apt-get install libcunit1-dev |
| 19 | }}} |
| 20 | Optional packages for building documentation: |
| 21 | {{{ |
| 22 | sudo apt-get install xsltproc docbook-xsl imagemagick |
| 23 | }}} |
| 24 | (for building PDF documentation, add `dblatex`, but expect a large download) |
| 25 | |
| 26 | === Build GEOS 3.3.2 === |
| 27 | PostGIS 2.0 requires GEOS >= 3.3.2 for topology support, however Ubuntu 10.04 only has GEOS 3.1.0 available in packages, so it needs to be built from source. Even if you don't need topology, you still need to build this package. |
| 28 | |
| 29 | There are multiple ways to build GEOS, but this is the simplest: |
| 30 | {{{ |
| 31 | wget http://download.osgeo.org/geos/geos-3.3.2.tar.bz2 |
| 32 | tar xvfj geos-3.3.2.tar.bz2 |
| 33 | cd geos-3.3.2 |
| 34 | ./configure |
| 35 | make |
| 36 | sudo make install |
| 37 | }}} |
| 38 | |
| 39 | == Build PostGIS == |
| 40 | {{{ |
| 41 | wget http://postgis.refractions.net/download/postgis-2.0.0beta2SVN.tar.gz |
| 42 | tar xfvz postgis-2.0.0beta2SVN.tar.gz |
| 43 | cd postgis-2.0.0beta2SVN |
| 44 | }}} |
| 45 | PostGIS 2.0 can be configured to disable topology or raster extensions, using the configure flags `--without-raster` and `--without-topology`. The default is to build both extensions: |
| 46 | {{{ |
| 47 | ./configure |
| 48 | make |
| 49 | sudo make install |
| 50 | sudo make comments-install |
| 51 | }}} |
| 52 | |
| 53 | == Template == |
| 54 | Complete a post-install by creating 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. |
| 55 | {{{ |
| 56 | sudo -u postgres createdb template_postgis |
| 57 | sudo -u postgres createlang plpgsql template_postgis |
| 58 | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/postgis.sql |
| 59 | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/spatial_ref_sys.sql |
| 60 | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/postgis_comments.sql |
| 61 | }}} |
| 62 | |
| 63 | === Enable raster extension === |
| 64 | Adding on to `template_postgis`: |
| 65 | {{{ |
| 66 | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/rtpostgis.sql |
| 67 | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/raster_comments.sql |
| 68 | }}} |
| 69 | |
| 70 | === Enable topology extension === |
| 71 | Adding on to `template_postgis`: |
| 72 | {{{ |
| 73 | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/topology.sql |
| 74 | sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis-2.0/topology_comments.sql |
| 75 | }}} |
| 76 | |
| 77 | == See also == |
| 78 | * https://help.ubuntu.com/community/PostgreSQL |