Original Link: http://anujjaiswal.wordpress.com/2011/06/14/installing-postgres9-0-and-postgis-on-centos/
So, I work with spatial (GIS) data quite often. Since quite often I have to rebuild databases I am going to write down the steps I take to install PostGIS + Postgresql. The first step on CentOS is to configure the repositories:
- Update /etc/yum.repos.d/CentOS-Base.repo, add the line exclude=postgresql* so that it will look like
[base]
name=CentOS-$releasever – Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
exclude=postgresql*
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
- Use http://www.pgrpms.org/ for postgresql. As root, go to /etc/yum.repo.d/ and create a file called pgrpms9.repo and add the following lines:
- Add EPEL repository by doing the following from shell:
- Update CentOS base repository to remove postgresql being downloaded by adding “exclude=postgresql*” to the end of the repo Centos-Base.repo
- Install PostGRES server, PostGIS, GEOS and PROJ on x86_64 using yum from shell prompt as given the command below:
- Install PostGRES server, PostGIS, GEOS and PROJ on i386 linux using yum from shell prompt as given the command below:
- Initialize and Start Postgres Database server
- Create PostGIS template database
- Create PostGRES database using postgis_template template database
[pgdg90]
name=PostgreSQL 9.0 $releasever - $basearch
baseurl=http://yum.pgrpms.org/9.0/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
[pgdg90-source]
name=PostgreSQL 9.0 $releasever – $basearch – Source
failovermethod=priority
enabled=0
baseurl=http://yum.pgrpms.org/srpms/9.0/redhat/rhel-$releasever-$basearch
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
su -c 'rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm'
$ yum install postgresql90-contrib.x86_64 postgresql90-docs.x86_64 postgresql90-devel.x86_64 postgis90 postgis90-utils postgis90-docs postgresql90-server.x86_64 proj-devel.x86_64 geos-devel.x86_64
$ yum install postgresql90-contrib postgresql90-docs postgresql90-devel postgis90 postgis90-utils postgis90-docs postgresql90-server proj-devel geos-devel
$ /sbin/service postgresql-9.0 initdb
$ /sbin/service postgresql-9.0 start
$ su - postgres
$ createdb -E UTF8 -T template0 postgis_template
$ createlang -d postgis_template plpgsql
$ psql -d postgis_template -f /usr/pgsql-9.0/share/contrib/postgis-1.5/postgis.sql
$ psql -d postgis_template -f /usr/pgsql-9.0/share/contrib/postgis-1.5/spatial_ref_sys.sql
$ psql -d postgis_template -c "GRANT ALL ON geometry_columns TO PUBLIC;"
$ psql -d postgis_template -c "GRANT ALL ON geography_columns TO PUBLIC;"
$ psql -d postgis_template -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
$ psql -d postgis_template -c "VACUUM FULL;"
$ psql -d postgis_template -c "VACUUM FREEZE;"
$ psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='postgis_template';"
$ psql -d postgres -c "UPDATE pg_database SET datallowconn='false' WHERE datname='postgis_template';"
$ su - postgres
$ psql -Upostgres
$ create role owner with createdb createrole login;
$ create database db with owner=owner template=postgis_template;
No comments:
Post a Comment