Skip to content

Instantly share code, notes, and snippets.

@DrOctogon
Forked from juniorz/install_postgis_osx.sh
Created August 18, 2014 21:03
Show Gist options
  • Save DrOctogon/686fafdcc8b1be95f8e8 to your computer and use it in GitHub Desktop.
Save DrOctogon/686fafdcc8b1be95f8e8 to your computer and use it in GitHub Desktop.

Revisions

  1. @juniorz juniorz revised this gist Jun 11, 2012. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions install_postgis_osx.sh
    Original file line number Diff line number Diff line change
    @@ -15,8 +15,12 @@ createdb postgis_template
    createlang plpgsql postgis_template

    #[Mac OSX] 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
    psql -d postgis_template -f /usr/local/Cellar/postgis/2.0.0/share/postgis/postgis.sql
    psql -d postgis_template -f /usr/local/Cellar/postgis/2.0.0/share/postgis/spatial_ref_sys.sql

    # If you want Raster support
    psql -d postgis_template -f /usr/local/Cellar/postgis/2.0.0/share/postgis/rtpostgis.sql
    psql -d postgis_template -f /usr/local/Cellar/postgis/2.0.0/share/postgis/topology.sql

    #Test if works
    psql -d postgis_template -c "SELECT postgis_full_version();"
  2. @juniorz juniorz revised this gist Aug 3, 2011. 2 changed files with 5 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion install_postgis_osx.sh
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,7 @@ ALTER TABLE spatial_ref_sys OWNER TO gisgroup;
    CREATE SCHEMA gis_schema AUTHORIZATION gisgroup;
    \q

    #4. Adds an app to your application
    #4. Adds your app's user
    createuser -i -l -S -R -d <app_user>

    psql -d postgres
    5 changes: 4 additions & 1 deletion install_postgis_ubuntu.sh
    Original file line number Diff line number Diff line change
    @@ -35,12 +35,15 @@ ALTER TABLE spatial_ref_sys OWNER TO gisgroup;
    CREATE SCHEMA gis_schema AUTHORIZATION gisgroup;
    \q

    #4. Adds an app to your application
    #4. Adds your app's user
    createuser -i -l -S -R -d <app_user>

    psql -d postgres
    GRANT gisgroup TO <app_user>;
    \q

    # Note: Remember to adding the <app_user> to your /etc/postgresql/8.4/main/pg_hba.conf
    # Example: local all <app_user> trust

    #5. Create your app database
    createdb -T postgis_template -O <app_user> <app_db>;
  3. @juniorz juniorz revised this gist Aug 3, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions install_postgis_ubuntu.sh
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,9 @@
    #1. Install PostgreSQL postgis and postgres

    sudo apt-get install postgresql-8.4 postgresql-client-8.4 postgresql-contrib-8.4

    # Maybe you may need to install from this repository:
    # https://launchpad.net/~ubuntugis/+archive/ubuntugis-unstable
    sudo apt-get install postgresql-8.4-postgis

    #2. Create a template to be used on creating GIS-enabled databases
  4. @juniorz juniorz revised this gist Jul 20, 2011. 2 changed files with 52 additions and 12 deletions.
    21 changes: 9 additions & 12 deletions install_postgis.sh → install_postgis_osx.sh
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,27 @@
    # 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/
    # http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392

    #1. Install PostgreSQL postgis and postgres

    #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
    #2. Create a template to be used on creating GIS-enabled databases

    createdb postgis_template
    createlang plpgsql postgis_template

    #Import Postgis Data
    #[Mac OSX] 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
    #3. Set template permissions to gisgroup
    createuser -R -S -L -D -I gisgroup;

    psql -d postgis_template
    @@ -33,13 +31,12 @@ ALTER TABLE spatial_ref_sys OWNER TO gisgroup;
    CREATE SCHEMA gis_schema AUTHORIZATION gisgroup;
    \q


    #Adds an app user
    #4. Adds an app to your application
    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>
    #5. Create your app database
    createdb -T postgis_template -O <app_user> <app_db>;
    43 changes: 43 additions & 0 deletions install_postgis_ubuntu.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    # 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/
    # http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392

    #1. Install PostgreSQL postgis and postgres

    sudo apt-get install postgresql-8.4 postgresql-client-8.4 postgresql-contrib-8.4
    sudo apt-get install postgresql-8.4-postgis

    #2. Create a template to be used on creating GIS-enabled databases

    sudo su postgres

    createdb postgis_template
    createlang plpgsql postgis_template

    #Import Postgis Data
    psql -d postgis_template -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
    psql -d postgis_template -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql

    #Test if works
    psql -d postgis_template -c "SELECT postgis_full_version();"

    #3. Set template permissions to gisgroup
    createuser -R -S -L -D -I gisgroup;

    psql -d postgis_template
    ALTER DATABASE postgis_template OWNER TO gisgroup;
    ALTER TABLE geometry_columns OWNER TO gisgroup;
    ALTER TABLE spatial_ref_sys OWNER TO gisgroup;
    CREATE SCHEMA gis_schema AUTHORIZATION gisgroup;
    \q

    #4. Adds an app to your application
    createuser -i -l -S -R -d <app_user>

    psql -d postgres
    GRANT gisgroup TO <app_user>;
    \q

    #5. Create your app database
    createdb -T postgis_template -O <app_user> <app_db>;
  5. @juniorz juniorz revised this gist Jul 14, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions install_postgis.sh
    Original file line number Diff line number Diff line change
    @@ -27,6 +27,7 @@ psql -d postgis_template -c "SELECT postgis_full_version();"
    createuser -R -S -L -D -I gisgroup;

    psql -d postgis_template
    ALTER DATABASE postgis_template OWNER TO gisgroup;
    ALTER TABLE geometry_columns OWNER TO gisgroup;
    ALTER TABLE spatial_ref_sys OWNER TO gisgroup;
    CREATE SCHEMA gis_schema AUTHORIZATION gisgroup;
  6. @juniorz juniorz created this gist Jul 14, 2011.
    44 changes: 44 additions & 0 deletions install_postgis.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    # 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>