Building and Installing PostGIS from Source

Prerequisites

PostgreSQL

You need to already have PostgreSQL, its dev package, and it libraries installed. On Fedora-based distributions, it looks like this:

[root@branchpoint build]# rpm -qa | sort | grep -i postgresql 
postgresql92-9.2.9-1.46.amzn1.x86_64
postgresql92-devel-9.2.9-1.46.amzn1.x86_64
postgresql92-libs-9.2.9-1.46.amzn1.x86_64
postgresql92-server-9.2.9-1.46.amzn1.x86_64
postgresql92-server-compat-9.2.9-1.46.amzn1.x86_64
[root@branchpoint build]#

 Eat Your Wheaties

  1. Setup local time zone.
  2. Update installed packages.
  3. Reboot.
sudo ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime
sudo yum update -y
sudo shutdown -r now

Install Essential Prerequisite Packages

 

sudo yum groupinstall "Development Tools"
sudo yum -y install readline-devel
sudo yum -y install zlib-devel libxml2-devel wget vim

 Build PostGIS Prerequisites

For each of the following  libraries, we go through these steps:

  1. Configure, passing in –prefix=/usr  and –libdir=/usr/lib64 .
  2. Compile using make .
  3. Install using make .

Working Directory

cd ~
mkdir ~/build
cd build

 

proj4

 

wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz
gzip -d proj-4.8.0.tar.gz
tar -xvf proj-4.8.0.tar
cd proj-4.8.0
./configure --prefix=/usr --libdir=/usr/lib64
make -j4
sudo make install
cd ..

 

GEOS

This one takes a while. On a “medium” sized server, running 4 parallel build processes, it takes about 10 minutes.

wget http://download.osgeo.org/geos/geos-3.3.7.tar.bz2
bzip2 -d geos-3.3.7.tar.bz2
tar -xvf geos-3.3.7.tar
cd geos-3.3.7
./configure --prefix=/usr --libdir=/usr/lib64
make -j4
sudo make install
cd ..

 

JSON-C

 

wget http://oss.metaparadigm.com/json-c/json-c-0.9.tar.gz
gzip -d json-c-0.9.tar.gz
tar -xvf json-c-0.9.tar
cd json-c-0.9
./configure --prefix=/usr --libdir=/usr/lib64
make -j4
sudo make install
cd ..

 

GDAL

This one takes a full 20 minutes to build.

wget http://download.osgeo.org/gdal/gdal-1.9.2.tar.gz
gzip -d gdal-1.9.2.tar.gz
tar -xvf gdal-1.9.2.tar
cd gdal-1.9.2
./configure --prefix=/usr --libdir=/usr/lib64
make -j4
sudo make install
cd ..

 

 PostGIS

Now that we have all the dependencies installed, building and installing PostGIS from source is relatively quick.

wget http://download.osgeo.org/postgis/source/postgis-2.1.3.tar.gz
tar xfz postgis-2.1.3.tar.gz
cd postgis-2.1.3
./configure --prefix=/usr --libdir=/usr/lib64
make
sudo make install
sudo ldconfig
sudo make comments-install
cd ..

 

 

 

Leave A Reply