PostGIS Basics - Part 1 - Installation
Why PostGIS?
PostGIS (good writeup) is actually the main reason I chose to go with PostgreSQL over MySQL for this new project I'm working on (there are many other benefits, though, and I really can't see myself ever going back). I'll leave the discussion of capabilities for another post, but for now I thought I'd share my experience installing and configuring this (very) squirrely extension to PostgreSQL.
Installation
Using the official documentation (which, unfortunately and like every other linux application, assumes that you are compiling from source) and a very helpful PostGIS basics guide I was able to get 90% there.
My OS is CentOS, so I used yum to handle installs from the rpm database. The thing with CentOS is that it is purposefully one step behind the cutting edge, so the most recent version of certain applications are not available (PHP, Postgres, etc). To get around this limitation, you have to instruct CentOS to look elsewhere for updated RPMs.
One location is the Postgresql repository: http://www.postgresql.org/download/linux
Another location for these is DAG. To set this as an additional rpm source, run this command as root (this works for RHEL 5 and CentOS):
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
Now we have the ability to get more up-to-date rpms.
Next, we must work on getting all of the dependencies for PostGIS installed, which amount to:
Proj4
Unfortunately, rpms for the proj-4 application still weren't available from the repository, so I found an rpm here: Proj-4 rpms. This installed with a quick rpm -U software-2.3.4.rpm
GEOS
Geos is thankfully available from Dag, so yum should find it and install it. There may be some weird dependencies you will have to work through. The below packages should help, but they'll all have to be installed eventually, so you may as well go ahead and do it.
- php-pear
- php-devel
* At this point, if you are using PDO and haven't installed the pgsql PDO drivers, you can do it now: "pecl install pdo_pgsql"
PL/pgSQL
You'll need to run the following commands from a command line (either as root or the postgres user, I can't recall which one is needed by which). Please note all of these paths seem to be unique to each installation, so yours might be different.
/usr/bin/initdb -D /var/lib/pgsql/data_dir //Create the database psql create language plpgsql psql -d database_name -f /usr/share/pgsql/contrib/lwpostgis.sql psql -d database_name -f /usr/share/pgsql/contrib/spatial_ref_sys.sql
The last two lines load the spacial functions into the database for use.
Posted by Jeremy Tunnell on August 26th 9:01 PM
Tags
PostGIS PostgreSQL
Comments
Thanks for information. I have successfully install Postgis on CentOS...
Posted by Wahyu Wijanarko on April 26th 01:25:14 AM