Skip to content

Instantly share code, notes, and snippets.

@binarymatt
Created July 27, 2012 15:22
Show Gist options
  • Save binarymatt/3188630 to your computer and use it in GitHub Desktop.
Save binarymatt/3188630 to your computer and use it in GitHub Desktop.
Postgis on a mac

Developer Setup

  1. Setup homebrew:

    /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
    

    Then:

    brew tap homebrew/versions
    
  2. Install required libraries:

    easy_install numpy
    

    Then:

    brew install geos proj gdal postgresql postgis15
    
  3. Initialize the server:

    initdb /usr/local/var/postgres
    
  4. May need to start postgres manually:

    pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
    

    Or stop:

    pg_ctl -D /usr/local/var/postgres stop -s -m fast
    
  5. Setup template database:

    createdb -E UTF8 template_postgis
    psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
    POSTGIS_SQL_PATH=/usr/local/Cellar/postgis15/1.5.3/share/postgis
    psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
    psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
    psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
    psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
    psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
    
  6. Set up database:

    createdb sampledb -T template_postgis
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment