Forked from panchicore/geodjango: ubuntu: postgresql 9 - postgis 1.5
Created
April 29, 2013 17:06
-
-
Save cristiangrojas/5483063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get install python-software-properties | |
sudo add-apt-repository ppa:pitti/postgresql | |
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable | |
sudo apt-get update | |
sudo apt-get install -y postgresql-9.0 postgresql-server-dev-9.0 postgresql-contrib-9.0 proj libgeos-3.2.2 libgeos-c1 libgeos-dev libgdal1-1.7.0 libgdal1-dev build-essential libxml2 libxml2-dev checkinstall | |
psql --version | |
wget http://postgis.refractions.net/download/postgis-1.5.2.tar.gz | |
tar zxvf postgis-1.5.2.tar.gz && cd postgis-1.5.2/ | |
sudo ./configure && sudo make && sudo checkinstall --pkgname postgis-1.5.2 --pkgversion 1.5.2-src --default | |
sudo su - postgres | |
POSTGIS_SQL_PATH=`pg_config --sharedir`/contrib/postgis-1.5 | |
createdb -E UTF8 template_postgis | |
createlang -d template_postgis plpgsql | |
psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_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;" | |
createdb -T template_postgis demo_geo_database | |
createuser --createdb -P <user de ubuntu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install python-software-properties | |
add-apt-repository ppa:ubuntugis/ubuntugis-unstable | |
add-apt-repository ppa:pitti/postgresql | |
add-apt-repository ppa:pi-deb/gis | |
apt-get update | |
apt-get install postgresql-9.0-postgis | |
A basic template database can be created with the following commands: | |
sudo su - postgres | |
createdb template_postgis | |
psql -q -d template_postgis -f /usr/share/postgresql/9.0/contrib/postgis-1.5/postgis.sql | |
psql -q -d template_postgis -f /usr/share/postgresql/9.0/contrib/postgis-1.5/spatial_ref_sys.sql | |
psql -q -d template_postgis -f /usr/share/postgresql/9.0/contrib/postgis_comments.sql | |
cat <<EOS | psql -d template_postgis | |
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; | |
REVOKE ALL ON SCHEMA public FROM public; | |
GRANT USAGE ON SCHEMA public TO public; | |
GRANT ALL ON SCHEMA public TO postgres; | |
GRANT SELECT, UPDATE, INSERT, DELETE | |
ON TABLE public.geometry_columns TO PUBLIC; | |
GRANT SELECT, UPDATE, INSERT, DELETE | |
ON TABLE public.spatial_ref_sys TO PUBLIC; | |
EOS | |
To test database creation you can do the following: | |
createdb --template template_postgis test_gis | |
psql -d test_gis -c "select postgis_lib_version();" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment