wiki:GeostackServer

The Open Source GIS Server Stack

  • circa late 2009/ early 2010

This recipe for developing a GIS server has proven effective, rock-solid, scalable and very fast. It's bare-bones, but everything works exceptionally well together and has proven responsive to both Google Maps and OpenLayers javascript APIs in the browser. A good GIS developer can take this server configuration and quickly turn out a robust back-end to a very high-quality web map application. This Geostack is pretty much the gold standard in the open source GIS community.

Lots of new releases happened late spring 2010, and I'll be updating this page as I experiment with the bleeding-edge. The Geostack described below has proven highly reliable so use my italicized suggestions with some caution.


Ubuntu

I've been using Ubuntu 8.04 (Hardy) for some time; it's proven stable and fast in a server setting.

It may be time to try moving to 10.04 Lucid Edition? Seems to be supported well on Amazon EC2...


Apache

Apache 2.0 is the standard. It may be installed using aptitude or apt-get.

note: Apache 2.2 has some new useful features but isn't available yet with aptitude/apt-get. Compile from source following this:  http://wiki.slicehost.com/doku.php?id=get_started_with_your_new_ubuntu_slice&s=virtual%20host%20setup


Postgres

Postgresql 8.3 with PostGIS is what makes the whole Geostack useful. Version 7.4, 8.1, 8.2 all work well, but you need to be current with PostGIS as there's good stuff in each new release. You must install the PL/pgSQL language for PostGIS to work.

note: Do NOT install PostGIS from aptitude/apt-get while installing postgres. You need to do some prerequisite installs and get the latest version.


PHP

PHP5. No reason for anything else; PHP is light and it just works. Some prefer Perl (fine.).

note: Don't forget to add the PostgreSQL module for php5 so you can access your database with PHP. Also, if you're going to access any external db you'll need those modules ( i.e.; aptitude install php5-pgsql php5-sybase )

A good PHP framework like CodeIgnigter is useful for rapid development, as well as PHP MapScript if you're installing Mapserver later.


GIS Dependencies

Here's where the rubber meets the road. Getting these dependencies working together correctly will provide seamless application development; getting it wrong can have you pulling your hair out down the road. This is what works for me:

GEOS

This is the geometry engine, maintained by The Open Source Geospatial Foundation  http://www.osgeo.org/. Use the latest (Geos-3.2.2) from here:  http://download.osgeo.org/geos/geos-3.2.2.tar.bz2.

Proj.4

The cartographic projection library  http://trac.osgeo.org/proj/. Proj-4.7.0 is the latest; use it.

You will need both the projection library and the datum shift grids:  http://download.osgeo.org/proj/proj-4.7.0.tar.gz and  http://download.osgeo.org/proj/proj-datumgrid-1.5.zip

Alternate repository:  ftp://ftp.remotesensing.org/proj/proj-4.7.0.tar.gz and  ftp://ftp.remotesensing.org/proj/proj-datumgrid-1.5.zip

Fun fact: Version 4.7 includes the projection commonly referred to as Spherical Mercator (or The Google Projection) which has been adopted by the major commercial web map APIs. Use ESPG 900913 (search for Spherical Mercator to see discussion in the GIS community on whether this is a legitimate map projection and if that even matters).

GDAL/OGR

Geospatial Data Abstraction Library, also maintained by OSGeo.org  http://www.osgeo.org/gdal_ogr , which they define as a translator library for raster geospatial data formats. The take-away is that this library is needed if you're going to serve raster images (think: tiles) and is a prerequisite for Mapserver WMS.

Version 1.6.0 note that "apt-get install gdal-bin" doesn't seem to give us what we need (errors in Mapserver install) I've had to compile from source in the past, which is a bit tricky. See:  http://trac.osgeo.org/gdal/wiki/BuildHints and  http://trac.osgeo.org/gdal/wiki/SupportedCompilers

Version 1.7.0 is now available  http://download.osgeo.org/gdal/gdalautotest-1.7.0.tar.gz as well as 1.7.1 and 1.7.2 but I've yet to try it.


PostGIS

Postgis-1.4.1 works well. You'll need at least version 1.3.4 to utilize GeoJSON natively (highly recommended).

Version 1.5.1 was distributed this spring and I suspect it's a must-use. You need to compile from source, after installing the GIS Dependencies listed above.

  1. ./configure --with-proj --with-geos --with-pgsql
  1. restart postgresql and create a project database
  1. run these sql commands to make the db a spatial one:

psql -f /usr/share/postgresql/8.3/contrib/postgis.sql -d <my_db>

psql -f /usr/share/postgresql/8.3/contrib/spatial_ref_sys.sql -d <my_db>

  1. don't forget to grant permissions on the two new PostGIS tables so you can edit down the road

Mapserver

With WMS Server to serve tiles to your web app. Version 5.4.2 More about Mapserver here:  http://mapserver.org/

note: very recently 5.6 has been released, and there's definitely some performance enhancements and new features that make this worth a look

Must be configured from source:  http://download.osgeo.org/mapserver/mapserver-5.4.2.tar.gz and the executable copied to the cgi-bin directory.