Installing PostgreSQL (and friends) from source on Ubuntu 12.04 (Precise Pangolin)

by gorthx

This is an update to this post from a few years back. This time I’m installing Postgres 9.2.3, PostGIS 2.0.1, and pgAdmin 1.17.0 on Ubuntu 12.04.

As usual, my default Pg install (–with-openssl –with-perl –with-libxml –prefix=/usr/local/[current_version]) required some extra packages (for headers):
libreadline6-dev
zlib1g-dev
libssl-dev
libxml2-dev
libperl-dev

All of these are easily installed via apt-get.

Next up, I wanted PostGIS 2.0. I don’t remember now why I thought it would be a good idea to install it from source. It took a little while to work through the package deps:
proj
libproj-dev
libxml2-dev already installed for Postgres
gettext-base
libjson0-dev
libgeos-3.2.2
libgdal1-1.7.0 and libgdal1-dev (optional; use if you want raster support [sure, why not?])

All of these are available in the standard repo, but I ran into some trouble with geos and gdal. The PostGIS README says geos 3.2.2 or higher is required, but it’s actually 3.3.2. (I suspect there’s a typo in the README.) So I had to install geos and gdal from source.

Then I could continue with the regular PostGIS install:
./configure
make && make check
sudo make install

Then, in psql:
create database geodb;
\c geodb
-- create language plpgsql ; --not necessary, this is installed by default in pg9.2 (HOORAY!)
\i /usr/local/postgres-9.2.3/share/contrib/postgis-2.0/postgis.sql
\i /usr/local/postgres-9.2.3/share/contrib/postgis-2.0/spatial_ref_sys.sql
\i /usr/local/postgres-9.2.3/share/contrib/postgis-2.0/postgis_comments.sql

:phew: On to pgadmin!

This requires:
libxslt1-dev
python-sphinx

I followed the directions in the INSTALL file to set up wxGTK – I got crazy amounts of errors from the libwxgtk2.8-0 and libwxgtk2.8-dev packages available in Ubuntu, and at this point I was getting tired of dealing with that.


So, to recap:
Packages for Pg:
libreadline6-dev
zlib1g-dev
libssl-dev
libxml2-dev
libperl-dev

Packages for PostGIS:
proj
libproj-dev
libxml2-dev already installed for Postgres
gettext-base
libjson0-dev
g++ (required to install geos)
geos-3.3.8 (from source)
gdal-1.9.2 (from source)

Packages for pgAdmin:
automake (for the bootstrap script)
libxslt1-dev
python-sphinx
wxGTK and friends, from source

References:
http://postgis.net/
http://stackoverflow.com/questions/10543552/postgis-2-0-0-install-geos-issue
http://trac.osgeo.org/geos
http://gdal.org

About these ads

5 Comments to “Installing PostgreSQL (and friends) from source on Ubuntu 12.04 (Precise Pangolin)”

  1. Gabrielle,

    If you installed with gdal (which enables raster support –with-raster to force it), you should be able to install postgis with:

    CREATE EXTENSION postgis;

    Also latest stable release is 2.0.3 so might as well use that if you are compiling from source.

    As far as GEOS. GEOS 3.2 is supported for 2.0 (or should be at any rate). It will disable some features though which is why its not recommended. Here is link to matrix of what works with what

    http://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS

    • Hi Regina!

      When I tried to compile PostGIS (2.0.1) with geos 3.2.2, it errored out with a message that 3.3.2 is required.

      Thanks for the tips. I feel like I need a do-over ;)

      • Hmm I’ll double check that. I usually compile with 3.3 so I wouldn’t have noticed it. But maybe Sandro actually listened to me this time that its confusing to disable parts if you compile with lower version and upped the requirement but didn’t change the docs. It could also be you are compiling with topology support. Topology needs 3.3 because there was a bug that was too big to backport the fix to 3.2.

  2. ticketed. http://trac.osgeo.org/postgis/ticket/2266 Come to think of it I think topology needed 3.2.3 or something like so probably still a bug somewhere.

  3. For the dependencies, it’s probably a lot easier to just type:

    apt-get build-dep postgresql-9.2

    Granted, it will get you a few more packages (since it lets you build with all the dependencies that the official packages get), but it’s just one step…

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: