In my last post I detailed my process for building PostgreSQL and PostGIS on Leopard. Problem is, it didn’t work. I was getting a strange crash when importing shape data. I’m not positive what the problem is but I would bet it was the liconv trickery…

In any case, I discovered that there are pre-built binaries for OS-X (Leopard compatible!) referenced from the PostGIS website. The maintainer has also packaged some require frameworks (GEOS and PROJ).

I’ve now got everything working (I think!) using the pre-compiled binaries. The steps are somewhat similar to those detailed in the other post. Here’s what I did:

PostgreSQL

  • Download the PostgreSQL dmg and run the installer. (I also installed the startup item)

PostGIS

  • Download the GEOS and PROJ images and run the installers.
  • Download the PostGIS dmg and run the installer

Initial DB Setup

  • Initialize the default db. (The installer readme says that it does this but it didn’t seem to…)
    $ sudo su postgres -c '/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data'
  • Create a new superuser:
    $ createdb -U postgres <user-name>
  • Create a postgis template database:

    • Connect to the template database
      $ psql template1

      • Execute the following commands:
        template1=# create database template_postgis with template = template1;
        template1=# UPDATE pg_database SET datistemplate = TRUE where datname = 'template_postgis';

      • Connect to the new template_postgis database:
        template1=# c template_postgis

      • Add PostGIS extensions and grant access to everyone to spatial tables:
        template_postgis=# CREATE LANGUAGE plpgsql;
        template_postgis=# i /usr/local/pgsql/share/lwpostgis.sql;
        template_postgis=# i /usr/local/pgsql/share/spatial_ref_sys.sql;
        template_postgis=# GRANT ALL ON geometry_columns TO PUBLIC;
        template_postgis=# GRANT ALL ON spatial_ref_sys TO PUBLIC;

      • Prevent further modifications to the template_postgis database:
        template_postgis=# VACUUM FREEZE;

Ruby

  • Install postgres nativ extensions
    • Get the gem sources
      $ sudo gem install postgres
    • The build will fail. Go to /usr/lib/ruby/user-gems/1.8/gems/postgres-0.7.1 and execute:
      $ sudo ruby extconf.rb --with-pgsql-dir=/usr/local/pgsql/
      $ sudo make && sudo make install
      $ sudo gem install postgres
  • Install GeoRuby
    $ sudo gem install GeoRuby
December 4, 2007 · Uncategorized · · [Print]

4 Comments to “Leopard, PostgreSQL and PostGIS from KyngChaos.com”

  1. [...] As Simple as Possible and No Simpler » Archive » Leopard, PostgreSQL and PostGIS from KyngChaos.co… postgres on leopard (tags: postgresql leopard osx) [...]

  2. [...] Postgres on Leopard Excellent article on installing Postgres from binaries on Leopard. Just make sure you have XCode installed [...]

  3. rkj says:

    Shouldn’t creating user look more like this: createuser -U postgres -s ? Thanks for great post :)

  4. creelay says:

    Hello guys! As i’m newbie here, i just want to say hello. By the way – bb code seems to work bad?

    cheers,

    creelay [url=http://forums.acdjapan.com/index.php?showuser=3659]how to order soma online Auckland[/url] http://forums.acdjapan.com/index.php?showuser=3659

Leave a Reply