A couple of people have asked this, so thought we would address the common issues people run into with compiling PostGIS.
The first question, some will ask is Why don't you just take the packaged PostGIS that comes with the PostgreSQL Yum repository?
There are two reasons for not installing PostGIS under using Yum and our general reasons for not.
NOTE: PostGIS 1.3, PostGIS 1.4, PostGIS 1.5 can coexist on the same PostgreSQL daemon service as long as they are installed in different databases. They will all share the same Proj and GEOS. So installing PostGIS 1.5 will not break your PostGIS 1.4 or 1.3 installs. The newer GEOS 3.2.0 C-API is backward compatible with older GEOS C-API and the C-API is what PostGIS uses.
Now that we answered the why, the next is How?. For this How section, we'll outline the things you need to compile first which are NOT packaged with PostGIS. We will also be focusing on the upcoming PostGIS 1.5. We will also outline the common issues people run into. Issues are most common on a 64-bit Linux Centos/Redhat EL.
Yum Installs you need. As mentioned you need to Yum install PostgreSQL and postgresql-devel.
If you run into issues like complaints about no gcc+ compiler, then you probably need to:
yum install gcc-c++
tar -xvf proj-4.6.1.tar.gz
unzip proj-datumgrid-1.4.zip -d proj-4.6.1/nad
tar -xvf geos-3.2.0.tar.bz2
make & make install
This is only needed for PostGIS 1.5+
tar -xvf libxml2-2.7.6.tar.gz
make & make install
You may swap this out with PostGIS 1.4.1 for mission critical production use, but we are demonstrating PostGIS 1.5 SVN. This is going to be a really exciting release once we get all our ducks in a row hopefully by early to Mid January 2010.
tar -xvf postgis-1.5.0SVN.tar.gz
Its very common to run into linking issues particularly with GEOS or Proj on a 64-bit that its either pointing at an old version or non-existent location. To detect said linking issues do the following:
ldd -d /usr/lib64/pgsql/postgis-1.5.so (to show all the dependencies (or ldd -d /usr/lib/pgsql/postgis-1.5.so if you are on 32-bit)
ldd -d /usr/lib64/pgsql/postgis-1.5.so | grep libgeos (or ldd -d /usr/lib/pgsql/postgis-1.5.so if you are on 32-bit)
ldd -d /usr/lib64/pgsql/postgis-1.5.so | grep libproj (or ldd -d /usr/lib/pgsql/postgis-1.5.so if you are on 32-bit)
You should get something of the form below which would tell me my geos is pointing at an older version
libgeos_c.so.1 => /usr/lib64/libgeos_c.so.1 libgeos-3.1.0.so => /usr/local/lib/libgeos-3.1.0.so (0x00110000)
To fix, may not be the best of solutions, but I destroy the symlinks and relink them something of the form:
ln -s /usr/local/lib/libgeos_c.so.1.6.0 /usr/lib64/libgeos_c.so.1
ln -s /usr/local/lib/libproj.so /usr/lib64/libproj.so.0
The insall path will be changing shortly -- but you can always find the sql files in the source folder: Here we are creating a template_postgis15.
createdb template_postgis15 -U postgres
psql -d template_postgis15 -U postgres -c "CREATE LANGUAGE plpgsql"
psql -d template_postgis15 -U postgres -f postgis/postgis.sql
psql -d template_postgis15 -U postgres -f spatial_ref_sys.sql
#this installs the help description for each function you can search via psql or pgadmin
psql -d template_postgis15 -U postgres -f doc/postgis_comments.sql
To verify all is good, run the below command in the database you just created using psql or PgAdminIII
You should get an output something like:
POSTGIS="1.5.0SVN" GEOS="3.2.0-CAPI-1.6.0" PROJ="Rel. 4.6.1, 21 August 2008" LIBXML="2.7.6" USE_STATS