Skip to content

Instantly share code, notes, and snippets.

@oscarfonts
Forked from rolo/gist:1481128
Created February 27, 2012 12:10
Show Gist options
  • Save oscarfonts/1923310 to your computer and use it in GitHub Desktop.
Save oscarfonts/1923310 to your computer and use it in GitHub Desktop.
Install Postgres 9.1, PostGIS and create PostGIS template on Ubuntu 11.10
#!/bin/bash
# Install Postgres 9.1 and PostGIS
sudo apt-get install postgresql-9.1 postgresql-9.1-postgis
# create template_postgis
sudo su postgres -c'createdb -E UTF8 -U postgres template_postgis'
sudo su postgres -c'createlang -d template_postgis plpgsql;'
sudo su postgres -c'psql -U postgres -d template_postgis -c"CREATE EXTENSION hstore;"'
sudo su postgres -c'psql -U postgres -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql'
sudo su postgres -c'psql -U postgres -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql'
sudo su postgres -c'psql -U postgres -d template_postgis -c"select postgis_lib_version();"'
sudo su postgres -c'psql -U postgres -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"'
sudo su postgres -c'psql -U postgres -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"'
sudo su postgres -c'psql -U postgres -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment