Installing PostGIS 1.2.0 with MacPorts PostgreSQL 8.1

In the previous post I detailed how to install PostgreSQL with MacPorts. This time we will see how to get the latest PostGIS (version 1.2.0 as of this writing) installed.

MacPorts provide PostGIS 1.1.1 but it depends on postgresql8 and we decided to go for the postgresql81 version last time. So we’ll have some handwork to get all run together.

First install proj and geos from MacPorts

sudo port install proj
sudo port install geos

then download, extract, compile and install PostGIS 1.2.0 :

curl -O http://postgis.refractions.net/download/postgis-1.2.0.tar.gz
tar xvzf postgis-1.2.0.tar.gz
cd postgis-1.2.0
./configure --libdir=/opt/local/lib/postgresql81/ --datadir=/opt/local/share/postgis --with-pgsql=/opt/local/lib/postgresql81/bin/pg_config --with-geos=/opt/local/bin/geos-config --with-prog=/opt/local/
make
sudo make install

Here we are, PostGIS 1.2.0 installed on a PostgreSQL 8.1.

Now every time you need to use PostGIS functions you need to configure your database (every new database need an “enabling phase”. You can use a template, but I will not cover this part) as follow :

createlang plpgsql yourdatabase
psql -f /opt/local/share/postgis/lwpostgis.sql -d your_database
psql -f /opt/local/share/postgis/spatial_ref_sys.sql -d your_database

[Update (04/01/2008) : Add missing /share/ in paths. thanks Galen]

If you already had an old version of PostGIS installed and want to upgrade your databases, follow the “UPGRADING EXISTING SPATIAL DATABASES” parts of PostGIS README.postgis.

Wed, 20 Dec 2006 12:47 Posted in ,

  1. By Galen @ Estately 09/04/2008 at 20h06


    Thanks for the how-to – I just changed everything to 1.3.2 and it worked. Hotness!

  2. By Galen @ Estately 09/04/2008 at 20h36


    One note: perhaps you forgot the share directory in the last 2 lines?

    psql -f /opt/local/share/postgis/lwpostgis.sql -d your_database
    psql -f /opt/local/share/postgis/spatial_ref_sys.sql -d your_database

  3. By Jonathan Tron 09/04/2008 at 21h23


    Galen : Thanks I will correct it straight away.

  4. By Matt 27/11/2011 at 17h20


    Hi Jonathon,

    Sorry to comment on such an old post, but I was hoping you could help me. I tried following your tutorial using macports to install postGIS and when I try to run postgis.sql I get the following error:

    ERROR: could not access file “$libdir/postgis-1.5”: No such file or directory"

    I can’t figure out how to fix this. Any help would be greatly appreciated!

Comment Installing PostGIS 1.2.0 with MacPorts PostgreSQL 8.1


RSS