| 1 | = How to install PostGIS 2.0 on CentOS 6 from packages = |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | As of July 2012, additional packages from [http://fedoraproject.org/wiki/EPEL 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. |
| 6 | |
| 7 | == Configure YUM == |
| 8 | |
| 9 | 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. |
| 10 | |
| 11 | Open the first file for editing: |
| 12 | {{{ |
| 13 | vi /etc/yum.repos.d/CentoOS-Base.repo |
| 14 | }}} |
| 15 | |
| 16 | On line 19, at the end of the `[base]` section, insert: |
| 17 | {{{ |
| 18 | exclude=postgresql* |
| 19 | }}} |
| 20 | |
| 21 | and near line 28 at the end of the `[updates]` section, insert again: |
| 22 | {{{ |
| 23 | exclude=postgresql* |
| 24 | }}} |
| 25 | |
| 26 | Save and close the file (with `vi`, press "esc" to go to command-mode, then type `:wq`). |
| 27 | |
| 28 | == Download and install PGDG RPM file == |
| 29 | |
| 30 | 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 |
| 31 | |
| 32 | For example, if you have a 64-bit OS and want to install PostgreSQL 9.1: |
| 33 | {{{ |
| 34 | curl -O http://yum.postgresql.org/9.1/redhat/rhel-6-x86_64/pgdg-centos91-9.1-4.noarch.rpm |
| 35 | rpm -ivh pgdg-centos91-9.1-4.noarch.rpm |
| 36 | }}} |
| 37 | |
| 38 | 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: |
| 39 | {{{ |
| 40 | rpm -ivh epel-release-6-7.noarch |
| 41 | }}} |
| 42 | |
| 43 | == Install PostGIS == |
| 44 | |
| 45 | Install everything with: |
| 46 | {{{ |
| 47 | yum install postgresql91-server postgis2_91 |
| 48 | }}} |
| 49 | |
| 50 | 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): |
| 51 | {{{ |
| 52 | service postgresql-9.1 initdb |
| 53 | service postgresql-9.1 start |
| 54 | chkconfig postgresql-9.1 on |
| 55 | }}} |
| 56 | |
| 57 | == Spatially enabling a database == |
| 58 | Spatially enabling a database using extensions is a new feature of PostgreSQL 9.1. |
| 59 | |
| 60 | Connect to your database using pgAdmin or psql, and run the following commands. To add postgis with raster support: |
| 61 | {{{ |
| 62 | CREATE EXTENSION postgis; |
| 63 | }}} |
| 64 | |
| 65 | To add topology support, a second extension can be created on the database: |
| 66 | {{{ |
| 67 | CREATE EXTENSION postgis_topology; |
| 68 | }}} |