Skip to content

Instantly share code, notes, and snippets.

@dmeehan
Forked from juniorz/install_postgis_osx.sh
Last active December 21, 2015 06:19
Show Gist options
  • Select an option

  • Save dmeehan/6263171 to your computer and use it in GitHub Desktop.

Select an option

Save dmeehan/6263171 to your computer and use it in GitHub Desktop.
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
#Installs postgis and postgres
brew install postgis
#Do it only at first start
initdb /usr/local/var/postgres
#Starts the database manually
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
#Creates a template to be used on creating GIS-enabled databases
createdb postgis_template
createlang plpgsql postgis_template
#Import Postgis Data
psql -d postgis_template -f /usr/local/Cellar/postgis/1.5.3/share/postgis/postgis.sql
psql -d postgis_template -f /usr/local/Cellar/postgis/1.5.3/share/postgis/spatial_ref_sys.sql
#Test if works
psql -d postgis_template -c "SELECT postgis_full_version();"
#Permissions
createuser -R -S -L -D -I gisgroup;
psql -d postgis_template
ALTER TABLE geometry_columns OWNER TO gisgroup;
ALTER TABLE spatial_ref_sys OWNER TO gisgroup;
CREATE SCHEMA gis_schema AUTHORIZATION gisgroup;
\q
#Adds an app user
createuser -i -l -S -R -d <app_user>
psql -d postgres
GRANT gisgroup TO <app_user>;
\q
#Database creation
createdb -T postgis_template -O <app_user> <app_db>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment