|Version 1 (modified by mwtoews, 10 months ago)|
How to install PostGIS 2.0 on CentOS 6 from packages
This installation method uses YUM packages maintained by Devrim GUNDUZ of the PostgreSQL Global Develompent Group (PGDG). For an overview of installing PostgreSQL using this method, see other details at http://wiki.postgresql.org/wiki/YUM_Installation.
As of July 2012, additional packages from EPEL 6 (Extra Packages for Enterprise Linux) are required to fulfill requirements for GDAL. These packages may be included as part of PGDG in future relese.
Log into the system with root access. These instructions assume that you are using a command-line editor vi, however use whatever text utility you are comfortable with.
Open the first file for editing:
On line 19, at the end of the [base] section, insert:
and near line 28 at the end of the [updates] section, insert again:
Save and close the file (with vi, press "esc" to go to command-mode, then type :wq).
Download and install PGDG RPM file
A PGDG RPM file needs to be downloaded for your platform and your PostgreSQL version requirements (you can choose the later). Find the correct RPM file for your system from here: http://yum.postgresql.org/repopackages.php
For example, if you have a 64-bit OS and want to install PostgreSQL 9.1:
curl -O http://yum.postgresql.org/9.1/redhat/rhel-6-x86_64/pgdg-centos91-9.1-4.noarch.rpm rpm -ivh pgdg-centos91-9.1-4.noarch.rpm
Currently, as second repository EPEL 6, is required for additional packages for GDAL. For all platforms, download the epel-release-6-7.noarch file from http://download.fedoraproject.org/pub/epel/6/i386/repoview/epel-release.html which will select your local mirror. Install the RPM:
rpm -ivh epel-release-6-7.noarch
Install everything with:
yum install postgresql91-server postgis2_91
Now perform a few post-installation setup commands, in the order: (1) Initialize the database cluster (required), (2) start database (recommended, if you want to use it straight away), (3) allow it to start-up automatically on reboot (recommended):
service postgresql-9.1 initdb service postgresql-9.1 start chkconfig postgresql-9.1 on
Spatially enabling a database
Spatially enabling a database using extensions is a new feature of PostgreSQL 9.1.
Connect to your database using pgAdmin or psql, and run the following commands. To add postgis with raster support:
CREATE EXTENSION postgis;
To add topology support, a second extension can be created on the database:
CREATE EXTENSION postgis_topology;