Postgres 9.0.1, hstore, PostGIS 1.5.2, GEOS 3.2.2 & GDAL 1.7 on Ubuntu 10.04 Lucid

October 12, 2010

Ubuntu 10.04 / Lucid is the latest long term release that most of us will be using for our server deployments for now. Unfortunately, it was released just before the latest big releases in the FOSS GIS world: Postgres 9 and PostGIS 1.5.

Thankfully, it’s pretty simple to install these latest versions. Here is quick rundown of the steps needed to install a great OSS server-side GIS stack with all these new toys using easy to remove .deb packages. Tested on EC2 with the latest stock 10.04 server AMI (ami-60067832).

  • Postgresql 9.0.1 + hstore NoSQL columns
  • PostGIS 1.5.2
  • GEOS 3.2.2
  • Proj 4.7
  • GDAL 1.7.2
  • Spatialite 2.4 RC4

All components with test PostGIS database example

sudo add-apt-repository ppa:pitti/postgresql
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install -y postgresql-9.0 postgresql-server-dev-9.0 postgresql-contrib-9.0 proj libgeos-3.2.2 libgeos-c1 libgeos-dev libgdal1-1.7.0 libgdal1-dev build-essential libxml2 libxml2-dev checkinstall

wget http://postgis.refractions.net/download/postgis-1.5.2.tar.gz
tar zxvf postgis-1.5.2.tar.gz && cd postgis-1.5.2/
sudo ./configure && sudo make && sudo checkinstall --pkgname postgis-1.5.2 --pkgversion 1.5.2-src --default

sudo su postgres
createdb -U postgres test_gis
createlang -dtest_gis plpgsql
psql -U postgres -d test_gis -f /usr/share/postgresql/9.0/contrib/hstore.sql  #<= hstore bootstrap, thanks to Paul Smith
psql -U postgres -d test_gis -f /usr/share/postgresql/9.0/contrib/postgis-1.5/postgis.sql
psql -U postgres -d test_gis -f /usr/share/postgresql/9.0/contrib/postgis-1.5/spatial_ref_sys.sql
psql -U postgres -d test_gis -c"select postgis_lib_version();"
exit

If you just want PostgreSQL 9.0

sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.0

Thanks to James DeMichele & Brent Wood for feedback on the original (incorrect) article.

  • brent wood

    Um… the postgis package is only docs & loaders, no postgis there??

  • JamesD

    I am able to get Postgis installed via the above method. However, how do i create a postgis template database? I can’t seem to find the postgis.sql file after the install.

  • http://www.tokumine.com simon

    Thanks for the comments – The original article was just plain wrong (I must’ve been daydreaming or something). I’ve since updated it with a fully tested walkthrough and also added a simple example PostGIS database setup at the end to get you started.

    Let me know if you have any problems with it.

  • http://www.IMovedOn.org Bob Light

    I was hoping you knew when the repositories would be officially a part of the ubuntu lucid 10.04 LTS repositories…I’ve built a server based on your instructions..and it does work fine…but I’d love to use only stable repositories.

    Thanks for your help!!

  • http://bravenewmethod.wordpress.com tikonen

    Thanks for this, got it running with these steps.

  • http://pauladamsmith.com/ Paul Smith

    hstore functionality isn’t automatically available, like PostGIS, you have to execute a file of SQL commands to get it for a database. For this repo the file is at /usr/share/postgresql/9.0/contrib/hstore.sql so to append to the above example:

    $ psql -U postgres -d test_gis -f /usr/share/postgresql/9.0/contrib/hstore.sql

  • http://www.tokumine.com simon

    Thanks Paul, updated the post.

    Bob, I don’t think these repo’s will ever be part of 10.04 as standard. AFAIK 10.04 will only get security patches on the current available official packages.

  • Nils

    Thanks for the steps. I got it running quite fast with it. I recognised two small mistakes in writing (for those who copy and paste the commands):

    in the first line it hast to be: “sudo add-apt-repository …”
    in the make-line it hast to be “.. && sudo make &&::”, otherwise make will fail.

    Regards
    Nils

  • http://www.tokumine.com simon

    Thanks Nils, updated

  • msc

    Nice post!
    but where is the liblwgeom.so file? I can’t find in /usr/lib/postgresql/9.0/lib/ and /usr/lib/postgis doesn’t show up in the system? what did I missed?

  • http://www.tokumine.com simon

    I think postgis 1.5.2 debs are now in ubuntugis-unstable, so you’ll be able to skip the dl and compile of postgis and just add it to the list of packages installed va apt-get.

Previous post: Web GIS data payload benchmarks

Next post: UK 3G data coverage in national parks and protected areas