Personal tools
Home » Members » scw » Ubuntu Server Installation
Document Actions

Ubuntu Server Installation

by Matthew Perry last modified 16-05-2007 16:49

This document outlines the procedure for setting up our GIS server software including Zope, Plone, Apache, PHP, GDAL, GRASS, PostGIS, Mapserver, Mapnik and PrimaGIS. The Ubunutu package system, while including many GIS packages, doesn't contain the latest versions with the latest features we need so we turn to compiling everything from source where it is necessary. This document also explains other server setup details such as the file structure and implementation details for various components.

Initial Setup

Use the Ubuntu Dapper Drake install CD and install in server mode.

First uncomment out the universe and multiverse lines in /etc/apt/sources.list and comment the cdrom source. It should look something like this:

# deb cdrom:[Ubuntu 6.04 _Dapper Drake_ - Alpha i386 (20060310)]/ dapper main restricted
# deb cdrom:[Ubuntu 6.04 _Dapper Drake_ - Alpha i386 (20060310)]/ dapper main restricted
deb http://us.archive.ubuntu.com/ubuntu/ dapper main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
## Uncomment the following two lines to add software from the 'universe'
## repository.
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://us.archive.ubuntu.com/ubuntu/ dapper universe main restricted multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper universe
## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
#deb http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
#deb-src http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu dapper-security main restricted
deb-src http://security.ubuntu.com/ubuntu dapper-security main restricted
deb http://security.ubuntu.com/ubuntu dapper-security universe
deb-src http://security.ubuntu.com/ubuntu dapper-security universe

Now update the package list and do a system update:
sudo apt-get update
sudo apt-get dist-upgrade

Install some initial packages (some of which we will revist to configure later):

sudo apt-get install libreadline5 libreadline5-dev bison flex mysql-server-5.0 libsqlite3-dev \
sqlite3 libxerces27 libxerces27-dev libstdc++5-3.3-dev libstdc++5 python2.4-dev \
python2.4-numeric python2.4-numeric-ext expat libexpat1-dev curl libcurl3 \
libcurl3-openssl-dev libcurl3-dev libxml2 libxml2-dev unixodbc unixodbc-dev \
h5utils hdf5-tools libhdf5-serial-dev libhdf4g libhdf4g-dev libhdf4g-run netcdf-bin \
netcdfg-dev g++ gcc make ccache imagemagick xsltproc
sudo apt-get install gpsbabel avce00 shapelib unzip libmysql++-dev subversion cvs trac ssh

Set up ccache to speed up re-compile times:

sudo ln -s /usr/bin/ccache /usr/local/bin/gcc
sudo ln -s /usr/bin/ccache /usr/local/bin/g++

Base Libraries

Now create a src directory and start compiling some of the base dependencies:

export SRC=/usr/local/src

# ECW Drivers
# Registration required for download
cd $SRC
wget "http://ermapper.com/download_files/libecwj2-3.3-2006-09-06.zip"
unzip libecwj2-3.3-2006-09-06.zip
ln -s libecwj2-3.3 libecw
cd libecw/
./configure
make
sudo make install

# PROJ
cd $SRC
curl ftp://ftp.remotesensing.org/proj/proj-4.5.0.tar.gz | tar zxvf -
ln -s proj-4.5.0 proj
cd proj/nad
wget "ftp://ftp.remotesensing.org/proj/proj-datumgrid-1.3.zip"
unzip proj-datumgrid-1.3.zip
cd ..
./configure
make
sudo make install

# GEOS
cd $SRC
curl http://geos.refractions.net/geos-2.2.3.tar.bz2 | tar jxvf -
ln -s geos-2.2.3 geos
cd geos
./configure
make
sudo make install

# OGDI
cd $SRC
curl "http://easynews.dl.sourceforge.net/sourceforge/ogdi/ogdi-3.1.5.tar.gz" | tar zxvf -
ln -s ogdi-3.1.5 ogdi
cd ogdi-3.1.5
export TOPDIR=$SRC/ogdi
./configure --with-proj=/usr/local --with-expat --with-zlib
make
sudo make install

# OpenDAP/DODS
cd $SRC
curl ftp://ftp.unidata.ucar.edu/pub/opendap/source/libdap-3.7.5.tar.gz | tar zxvf -
ln -s libdap-3.7.5 libdap
cd libdap
./configure
make
sudo make install

# JASPER JPEG200
cd ~/src
wget "http://www.gdal.org/dl/jasper-1.900.0.uuid.tar.gz"
tar -xzvf jasper-1.900.0.uuid.tar.gz
ln -s jasper-1.900.0.uuid jasper
cd jasper
export CFLAGS='-fPIC'
./configure
make
sudo make install

# PostgreSQL
cd $SRC
curl ftp://ftp.us.postgresql.org/pub/mirrors/postgresql/source/v8.2.3/postgresql-8.2.3.tar.bz2 | tar jxvf -
ln -s postgresql-8.2.3/ postgresql
cd postgresql
./configure --prefix=/usr/local --with-python
make
sudo make install

# PostGIS
cd contrib
curl "http://postgis.refractions.net/download/postgis-1.2.1.tar.gz" | tar zxvf -
cd postgis-1.2.1
./configure
make
sudo make install

# PDFLib
cd $SRC
curl http://www.pdflib.com/binaries/PDFlib/700/PDFlib-Lite-7.0.0p3.tar.gz | tar zxvf -
ln -s PDFlib-Lite-7.0.0p3 pdflib
cd pdflib
./configure --with-ruby --with-rubyincl=/usr/lib/ruby/1.8/x86_64-linux/
make
sudo make install

# gpx2shp
cd ~/src
wget "http://prdownloads.sourceforge.jp/gpx2shp/13458/gpx2shp-0.69.tar.gz"
tar -xzvf gpx2shp-0.69.tar.gz
cd gpx2shp-0.69
./configure
make
sudo make install

GDAL

Now, finally, we can install GDAL with a good set of drivers:

# GDAL
curl "http://dl.maptools.org/dl/gdal/gdal-1.4.0.tar.gz" | tar xzvf -
ln -s gdal-1.4.0 gdal
cd gdal
./configure \
--with-threads \
--with-ngpython \
--with-curl=/usr/bin \
--with-ecw=/usr/local \
--with-dods-root=/usr/local \
--with-sqlite=/usr \
--with-odbc=/usr \
--with-geos=/usr/local/bin/geos-config \
--with-xerces \
--with-xerces-inc=/usr/include/xercesc \
--with-xerces-lib="-L/usr/lib -lxerces-c -lpthread" \
--with-mysql=/usr/bin/mysql_config
make
sudo make install

GRASS

Install GRASS from the CVS snapshot:

# First, some binary dependencies to take care of
sudo apt-get install freetype2 tcl8.3 tk8.3 tcl8.3-dev tk8.3-dev libmotif3 \
libmotif-dev libtiff4-dev libpng-dev libgl1-mesa-dev \
libglu1-mesa-dev fftw3-dev fftw3 freetype2-dev fftw2 \
fftw-dev libfreetype6-dev gettext
curl http://grass.itc.it/grass61/source/snapshot/grass-6.1.cvs_src_snapshot_2006_05_13.tar.gz | tar zxvf -
ln -s grass-6.3.cvs_src_snapshot_2007_02_17 grass
cd grass
export CFLAGS="-O2 -mcpu=opteron -m64"
./configure --with-cxx \
--with-gdal=/usr/local/bin/gdal-config \
--with-freetype \
--with-freetype-includes=/usr/include/freetype2 \
--with-nls \
--with-postgres \
--with-readline \
--with-postgres-includes=/usr/local/include/postgresql \
--with-tcltk-includes=/usr/include/tcl8.3 \
--enable-largefile \
--with-x \
--with-odbc \
--with-sqlite \
--with-mysql \
--with-mysql-includes=/usr/include/mysql \
--with-mysql-libs=/usr/lib \
--enable-64bit \
--with-libs=/usr/lib64
--with-python
make
sudo make install
sudo ln -s /usr/local/bin/grass61 /usr/local/bin/grass

Now we have to add the GRASS libs to ldconfig so the runtime linker catches them. Open /etc/ld.so.conf and add:

/usr/local/lib
/usr/local/grass-6.3.cvs/lib

then run

sudo ldconfig

Now we have to install the gdal/grass bridge in order to give GDAL/OGR read access to GRASS rasters and vectors respectively:

# gdal-grass plugin
cd $SRC
curl "http://www.gdal.org/dl/gdal-grass-1.3.2.tar.gz" | tar xzvf -
cd gdal-grass-1.3.2/
./configure --with-gdal=/usr/local/bin/gdal-config --with-grass=/usr/local/grass-6.3.cvs
make
sudo make install

R Statistics

Time to install R, the stats package along with some hooks for spatial data:

# R & all the spatial libraries
sudo apt-get install r-recommended
sudo R
install.packages(c("rgdal", "sp","maptools","gstat", "abind", "methods", "pixmap"), dependencies=TRUE)
q()

Apache

Apache is our webserver of choice for all non-CMS content:

sudo apt-get install apache2 libapache2-mod-python libapache2-mod-fastcgi
# Register some required modules
sudo a2enmod actions
sudo a2enmod ssl
sudo a2enmod rewrite
sudo a2enmod suexec
sudo a2enmod include
# Configure for PHP-CGI (prep for next step)
sudo vi /etc/apache2/apache2.conf
# Add
#
# For PHP scripts as CGI-BIN
#
AddType application/x-httpd-php-cgi .php .php4 .phtml
AddHandler application/x-httpd-php-cgi /cgi-bin/php4

# Add php scripts and html to /var/www

PHP web scripting

Because of thread safety issues and general lack of moderneity in the GIS stack, we have to use php4 as a CGI as opposed to an apache module:

cd ~/src
wget http://us3.php.net/get/php-4.4.2.tar.gz/from/this/mirror
tar -xzvf php-4.4.2.tar.gz
cd php-4.4.2
sudo apt-get install bzip2 libbz2-dev libxslt1-dev libgd2-noxpm-dev sablotron libsablot0-dev
./configure --enable-shared --with-regex=system --with-jpeg-dir=/usr \
--with-png-dir=/usr --with-zlib --with-gd=/usr --with-freetype-dir=/usr \
--enable-force-cgi-redirect --enable-dbase --without-pdflib --with-mysql \
--with-config-file-path=/usr/local/php4/ --prefix=/usr/local/php4 \
--enable-xslt \
--with-xslt-sablot=/usr \
--enable-fastcgi \
--with-openssl \
--with-kerberos \
--with-zlib \
--with-bz2 \
--with-curl \
--enable-dbase \
--with-gd \
--with-pgsql \
--with-xsl \
--with-mysql \
--with-gettext \
--with-regex=system
make
sudo make install
sudo mkdir /usr/local/php4/extensions
sudo cp ~/src/php-4.4.2/php.ini-dist /usr/local/php4/php.ini
sudo vi /usr/local/php4/php.ini
# Change
extension_dir="/usr/local/php4/extensions"
# copy php to cgi-bin
sudo cp /usr/local/php4/bin/php /usr/lib/cgi-bin/php4
sudo apache2ctl restart

Mapserver

OK after all that, we're finally ready to install Mapserver:

# Mapserver
cd ~/sr
wget http://cvs.gis.umn.edu/dist/mapserver-4.8.3.tar.gz
tar -xzvf mapserver-4.8.3.tar.gz
cd mapserver-4.8.3
./configure \
--without-tiff \
--with-jpeg \
--with-png \
--with-freetype \
--with-zlib \
--with-threads \
--with-proj \
--with-gdal=/usr/local/bin/gdal-config \
--with-wcs \
--with-ogr \
--with-wmsclient \
--with-wfsclient \
--with-wfs \
--without-pdf \
--with-geos \
--enable-debug \
--with-php=/home/perrygeo/src/php-4.4.2 \
--with-postgis=/usr/local/bin/pg_config \
--with-curl-config=/usr/bin/curl-config \
--with-httpd=/usr/sbin/apache2
make
sudo cp mapserv /usr/lib/cgi-bin/
sudo cp shp2img shptree shptreetst shptreevis sortshp tile4ms scalebar legend /usr/local/bin/

We need to prep our htdocs directory for mapserver to cache images:

mkdir ~/www/tmp
# Must be writable by web user and other apps
chmod 775 ~/www/tmp
sudo chown www-data ~/www/tmp
# Later you can configure your mapfile like so
# IMAGEPATH "/var/www/tmp/"
# IMAGEURL "/tmp/"

Create a shell script ( /usr/local/bin/cleantemp.sh ) to clean out this dir

#!/bin/sh
# clear out old temp images if they're over 2 hrs old
find /var/www/tmp -type f -amin +120 -exec rm {} \;

and add this as a cron task

export EDITOR=vi && crontab -e
# Add
00 03 * * * /usr/local/bin/cleantemp.sh

Now to install the Mapscript bindings for our favorite scripting languages:

# Mapscript (PHP)
sudo cp mapscript/php3/php_mapscript.so /usr/local/php4/extensions/php_mapscript.so
# Mapcript (Python)
cd mapscript/python
sudo apt-get install swig
swig -python -modern -o mapscript_wrap.c ../mapscript.i
sudo python setup.py install

Zope

Now for an alternate web server, our Zope system:

sudo apt-get install zope2.9 python2.4-imaging
export INSTANCE=ebm
sudo /usr/lib/zope2.9/bin/mkzopeinstance.py -d /var/lib/zope2.9/instance/${INSTANCE}
# give user pass at interactive prompt

Now install the Plone CMS on top of that. note that the URL below is for the beta version and hopefully the 2.5 final will be released by the time we install it:

cd ~/src
wget http://easynews.dl.sourceforge.net/sourceforge/plone/Plone-2.5.tar.gz
tar -xzvf Plone-2.5.tar.gz
cd Plone-2.5
sudo cp -r * /var/lib/zope2.9/instance/${INSTANCE}/Products/
sudo /var/lib/zope2.9/instance/${INSTANCE}/bin/zopectl start
# OR
sudo /etc/init.d/zope2.9 restart

And we may eventually need some of these python modules so we'll toss 'em in here:

# some additional useful python modules
sudo apt-get install python2.4-psycopg python-wxgtk2.4 python2.4-sqlite \
python-gtk2-dev python-pysqlite2 python-celementtree python-lxml python2.4-numarray python2.4-twisted \
python2.4-adodb python2.4-rpy python2.4-scipy python-cherrypy2.1 python2.4-reportlab python2.4-matplotlib

Mapnik

Now for some cutting edge cartography software, Mapnik. Ostensibly there is even a WMS server so it could be a nice alt. to mapserver

# mapnik
sudo apt-get install \
libboost-python1.33.1 libboost-python-dev \
libboost-regex1.33.1 libboost-regex-dev \
libboost-serialization-dev \
libboost-signals1.33.1 libboost-signals-dev \
libboost-thread1.33.1 libboost-thread-dev \
libboost-program-options1.33.1 libboost-program-options-dev \
libboost-filesystem1.33.1 libboost-filesystem-dev \
libboost-iostreams1.33.1 libboost-iostreams-dev
cd ~/src
svn checkout svn://svn.berlios.de/mapnik/trunk mapnik
cd mapnik
python scons/scons.py PYTHON=/usr/bin/python PGSQL_INCLUDES=/usr/local/include/postgresql \
PGSQL_LIBS=/usr/local/lib/postgresql BOOST_INCLUDES=/usr/include/boost BOOST_LIBS=/usr/lib
sudo python scons/scons.py install PYTHON=/usr/bin/python PGSQL_INCLUDES=/usr/local/include/postgresql \
PGSQL_LIBS=/usr/local/lib/postgresql BOOST_INCLUDES=/usr/include/boost BOOST_LIBS=/usr/lib
sudo ldconfig

Now to configure the experimental WMS server:

cd ~/src
wget http://easynews.dl.sourceforge.net/sourceforge/jonpy/jonpy-0.06.tar.gz
tar -xzvf jonpy-0.06.tar.gz
cd jonpy-0.06/
sudo python setup.py install

# copy the ogcserver stuff into its own dir
mkdir ~/mapnik; cd ~/mapnik
cp ~/src/mapnik/utils/ogcserver/* .
vi ogcserver.conf
module=worldMapFactory.py
maxheight=2048
maxwidth=2048

Create our module defining data sources, styles, etc.( worldMapFactory.py ) :

from mapnik.ogcserver.WMS import BaseWMSFactory
from mapnik import *
class WMSFactory(BaseWMSFactory):
def __init__(self):
BaseWMSFactory.__init__(self)
sty = Style()
rl = Rule()
rl.symbols.append(PolygonSymbolizer(Color(248,216,136)))
rl.symbols.append(LineSymbolizer(Color(228,196,126),1))
sty.rules.append( rl )

self.register_style('style1', sty)

lyr = Layer(name='layername', type='shape', \
file='/home/perrygeo/data/world_borders/world_borders')

lyr.styles.append('style1')
self.register_layer(lyr)
self.finalize()

Now we need to set up apache to handle fastcgi:

sudo apt-get install libapache2-mod-fcgid
sudo a2enmod fcgid

sudo vi /etc/apache2/sites-enabled/000-default
        ScriptAlias /fcgi-bin/ /usr/lib/fcgi-bin/
        <Directory "/usr/lib/fcgi-bin">
                AllowOverride All
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
                SetHandler fastcgi-script
        </Directory>

sudo mkdir /usr/lib/fcgi-bin

Now create the actual server script as /usr/lib/fcgi-bin/wms

#!/usr/bin/env python
# Your mapnik dir containing the map factory
# must be in the python path!
import sys
sys.path.append('/home/perrygeo/mapnik')
from mapnik.ogcserver.cgiserver import Handler
import jon.fcgi as fcgi
class WMSHandler(Handler):
    configpath = '/home/perrygeo/mapnik/ogcserver.conf'
fcgi.Server({fcgi.FCGI_RESPONDER: WMSHandler}).run()

In order to get Mapnik to accept non OGC parameters that some wms clients like to tack on (such as the UNIQUEID parameter for mapbuilder), we have to modify mapnik/ogcserver/common.py. You can simply comment out

        #for paramname in params.keys():
# if paramname not in self.SERVICE_PARAMS[requestname].keys():
 # raise OGCException(’Unknown request parameter “%s”.’ % paramname)

Restart Apache

sudo /etc/init.d/apache2 force-reload

Now you can access it with a WMS request like so:

http://192.168.1.46/fcgi-bin/wms?request=GetMap&service=WMS&version=1.1.1&layers=world_borders&BBOX=-180,-90,180,90&width=600&height=300&format=image/png&styles=&srs=EPSG:4326

Configure Postgresql

sudo adduser postgres
# run through interactive prompt
sudo su postgres
mkdir ~/data
chmod -R 700 data
/usr/local/bin/initdb -D /home/postgres/data
/usr/local/bin/pg_ctl start -D /home/postgres/data -l /home/postgres/data/logfile
vi /home/postgres/data/pg_hba.conf
# Change all 'trust' to 'md5' to force authentication
/usr/local/bin/psql -d gisdata -c "ALTER USER postgres WITH ENCRYPTED PASSWORD 'doublesecret'"
/usr/local/bin/pg_ctl restart -D /home/postgres/data -l /home/postgres/data/logfile
/usr/local/bin/createdb gisdata
/usr/local/bin/psql -d gisdata -c "CREATE USER perrygeo WITH CREATEUSER CREATEROLE CREATEDB ENCRYPTED PASSWORD 'shhh'"
/usr/local/bin/psql -d gisdata -c "GRANT ALL ON DATABASE gisdata TO perrygeo"
exit
# Now we can work from our normal user account
createlang plpgsql gisdata
psql -d gisdata -f /usr/local/share/postgresql/contrib/lwpostgis.sql
psql -d gisdata -f /usr/local/share/postgresql/contrib/spatial_ref_sys.sql

Create an debian rc init script


Using vi, create /etc/init.d/postgres

#! /bin/sh
# postgresql init.d script
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions
case "$1" in
start)
log_begin_msg "Starting postgresql server ..."
su postgres -c "/usr/local/bin/pg_ctl start -l /home/postgres/data/logfile -D /home/postgres/data"
log_end_msg $?
;;
stop)
log_begin_msg "Stoping postgresql server ..."
su postgres -c "/usr/local/bin/pg_ctl stop -D /home/postgres/data"
log_end_msg $?
;;
restart|force-reload)
log_begin_msg "Restarting postgresql server ..."
su postgres -c "/usr/local/bin/pg_ctl stop -D /home/postgres/data"
su postgres -c "/usr/local/bin/pg_ctl start -l //home/postgres/data/logfile -D /home/postgres/data"
log_end_msg $?
;;
*)
echo "Usage: /etc/init.d/postgres {start|stop|restart}"
exit 1
;;
esac
exit 0

Make sure it has the proper permissions

sudo chmod +x /etc/init.d/postgres

Then add the init script to the system startups

update-rc.d postgres defaults

Configure Mysql

mysqladmin -u root password doublesecret
mysql -u root -p
# enter at mysql> prompt
CREATE DATABASE gisdata
GRANT ALL PRIVILEGES ON gisdata.* TO 'perrygeo'@'localhost' IDENTIFIED BY 'shhh' WITH GRANT OPTION;
#login in as normal user
mysql -D gisdata -p

Extra Tools

DEM Processing

cd ~/src
mkdir gdaldemtools
cd gdaldemtools
wget "http://perrygeo.net/download/gdaldemtools_20060207.zip"
unzip gdaldemtools_20060207.zip
g++ hillshade.cpp -lgdal -o hillshade
g++ color-relief.cxx -lgdal -o color-relief
g++ aspect.cpp -lgdal -o aspect
g++ slope.cpp -lgdal -o slope
sudo cp slope aspect color-relief hillshade /usr/local/bin/

Starspan

sudo apt-get install autoconf2.13 automake1.8 checkinstall \
autobook autoconf-archive gnu-standards
cd ~/src# starspan
cvs -z3 -d:ext:perrygeo@cvs.casil.ucdavis.edu:/cvsroot/starspan checkout starspan
cd starspan
./reconf
./configure --with-gdal=/usr/local/bin/gdal-config --with-geos=/usr/local/bin/geos-config
make
make install

PyDap - OpenDAP/DODS server

# pyDap Server
cd ~/src
wget http://cheeseshop.python.org/packages/source/d/dap/dap-2.1.4.tar.gz
tar -xzvf dap-2.1.4.tar.gz
cd dap-2.1.4/
sudo python setup.py install
sudo easy_install paste

PrimaGIS Stack

Python Cartographic Library

cd ~/src
sudo svn checkout http://svn.gispython.org/gispy/PCL/trunk PCL
cd PCL/PCL-Cartography
sudo python setup.py build_ext -I ~/src/mapserver install
cd ../PCL-Referencing
sudo python setup.py build_ext -I ~/src/mapserver install
cd ../PCL-Spatial
sudo python setup.py install
cd ../PCL-Data
sudo python setup.py install
cd ../OWSlib
sudo python setup.py install
cd ../PCL-Mapserver
vi setup.py:
ms_home = /usr/local/src/mapserver
sudo python setup.py build sudo python setup.py install

This is the SVN version of PCL -- here be dragons.

Hit problems when trying to render the map with http://trac.gispython.org/projects/PCL/ticket/44.
As per Hobu's suggestion:

cd /usr/local/src/mapserver/mapscript/python/
vi mapscript_wrap.c:
/* comment out intarray_set method */
sudo python setup.py clean
sudo python setup.py build
sudo python setyp.py install

Zope Cartographic Objects

cd ~/src
wget http://gispython.org/downloads/zope/ZCO-0.7.3.tar.gz
tar -xzvf ZCO-0.7.3.tar.gz
export INSTANCE=ebm
sudo cp -R ZCO-0.7.3 /var/lib/zope2.9/instance/${INSTANCE}/Products/ZCO
sudo ln -s /usr/local/share/proj/epsg /usr/local/share/proj/EPSG

GeoAware Objects et. al.

cd ~/src
wget http://plone.org/products/cmfsin/releases/0.6.1/CMFSin-0.6.1.tar.gz
wget http://gispython.org/downloads/zope/GeoAwareObjects-0.2.0.tar.gz
tar -xzvf CMFSin-0.6.1.tar.gz
tar -xzvf GeoAwareObjects-0.2.0.tar.gz
sudo cp -R CMFSin /var/lib/zope2.9/instance/${INSTANCE}/Products/CMFSin
sudo cp -R GeoAwareObjects /var/lib/zope2.9/instance/${INSTANCE}/Products/GeoAwareObjects

PrimaGIS

# PrimaGIS
cd ~/src
wget http://gispython.org/downloads/zope/PrimaGIS-0.5.0.tar.gz
tar -xzvf PrimaGIS-0.5.0.tar.gz
sudo cp -r PrimaGIS/ /var/lib/zope2.9/instance/${INSTANCE}/Products/PrimaGIS

restart

sudo /etc/init.d/zope2.9 restart

Now to install the demo

wget http://www.mappinghacks.com/data/world_borders.zip
unzip world_borders.zip
vi create world_borders.ovf
# create
<OGRVRTDataSource>
<OGRVRTLayer name="world_borders">mkdir ~/data; cd ~/data; mkdir world_borders; cd world_borders
<SrcDataSource relativeToVRT="1">world_borders.shp</SrcDataSource>
<SrcLayer>world_borders</SrcLayer>
<LayerSRS>EPSG:4326</LayerSRS>
</OGRVRTLayer>
</OGRVRTDataSource>
mkdir ~/mapfiles; cd ~/mapfiles
vi fontset.txt
# create
Vera /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
georgia_bold /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf

all this has to be done in the ZMI

# create the plone site ('ebm')
# /ebm/portal_quickinstaller
# Select ALL products and click Install
# Point browser to http://host/ebm/portal_skins/primagis/createPrimaGISDemo
# in /ebm/demo/zco:
# point map renderer to proper text file
# point raw data to proper .ovf file

Debugging

http://host/ebm/demo/primagis/ shows :

<Products.CMFCore.PortalFolder.PortalFolderBase object at 0xab0902c>

http://host/ebm/demo/primagis/base_view shows the contents in text nstead of the map. 

Ahah. http://host/ebm/demo/primagis/primagis_view works. But the interface defaults to /ebm/demo/primagis/.

The fix is in ZMI: /ebm/portal_types/PrimaGISMap

Add primagis_view as the Default method under the alias tab.

Also, there is a problem with the Titles not showing up in the menu. Just go to the edit tab and resave it and it shows up. Wierd.


Web Maping Client Interfaces

kamap

cd ~/www
export CVSROOT=:pserver:cvsanon@cvs.maptools.org:/cvs/maptools/cvsroot
cvs login
cvs co ka-map
cd ka-map/include
cp config.dist.php config.php
vi config.php
# line 49 : php_mapscript.so
# $szBaseCacheDir = "/var/www/tmp/kacache/";
# $szBaseWebCache = "tmp/kacache/";

chmod 775 ~/www/tmp/kacache
mkdir ~/www/tmp/kacachesudo chown -R nobody ~/www/tmp/kacache

mapbuilder

cd ~/www
wget http://easynews.dl.sourceforge.net/sourceforge/mapbuilder/mapbuilder-lib-1.0-release.zip
unzip mapbuilder-lib-1.0-release.zip
# The demos are fully functional out-of-the-box since they hit external WMS servers. Check them out at http://host/mapbuilder/

 mww

cd ~/www
wget http://perrygeo.net/download/mww-lite.zip
unzip mww-lite.zip

wmsmap

cd ~/www
mkdir wmsmap; cd wmsmap
wget http://wms-map.sourceforge.net/wms_map.zip
unzip wms_map.zip

mscross

cd ~/www/mscross; cd ~/www/mscross
wget "http://datacrossing.crs4.it/download.php?l=en&id=mscross-1.1.2.js"
mv download.php\?l\=en\&id\=mscross-1.1.2.js mscross.js
# Get all the images and put them in /img mkdir ~/www/img; cd ~/www/img wget http://datacrossing.crs4.it/img/arrow_right.gif wget http://datacrossing.crs4.it/img/button_fullExtent.png wget http://datacrossing.crs4.it/img/button_loading.png wget http://datacrossing.crs4.it/img/button_pan.png wget http://datacrossing.crs4.it/img/button_zoombox.png wget http://datacrossing.crs4.it/img/button_zoomIn.png
wget http://datacrossing.crs4.it/img/button_zoomOut.png


Set up SVN and Trac Server

follow the instructions at http://projects.edgewall.com/trac/wiki/TracOnUbuntu

mkdir ~/svn
svnadmin create ~/svn
svn import ~/www/mww file:///home/perrygeo/svn/mww -m "initial import"

#If just using locally, you can check it out like so
svn co file:///home/perrygeo/svn/mww

#start the server daemon
svnserve -d -r /home/perrygeo/svn/
# check out using the svn:// address
svn co svn://localhost/mww
# Now check it out on a remote machine, make some edits to a file
# and commit them.
svn commit -m "first revision" mww.php
# Create an init.d script
sudo vi /etc/init.d/svnserve
-------------
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions
case "$1" in
start)
log_begin_msg "Starting subversion server ..."
su www-data -c "/usr/bin/svnserve -d -r /home/perrygeo/svn/"
log_end_msg $?
;;
stop)
log_begin_msg "Stoping subversion server ..."
su www-data -c "killall svnserve -u www-data"
log_end_msg $?
;;
restart|force-reload)
log_begin_msg "Restarting postgresql server ..."
su www-data -c "killall svnserve -u www-data"
su www-data -c "/usr/bin/svnserve -d -r /home/perrygeo/svn/"
log_end_msg $?
;;
*)
echo "Usage: /etc/init.d/svnserve {start|stop|restart}"
exit 1
;;
esac
exit 0
-------------
sudo update-rc.d svnserve defaults

Once SVN is working properly, you can set up Trac for the project management and web browsing of the svn repos. in this case I set it up as a CGI but it can also be done with mod_python.

-----
# everything else is default
project: EBM Projects
svn: /home/perrygeo/svn
-----
chmod -R 775 trac
sudo chown -R www-data trac

trac-admin ~/trac initenv
htpasswd -c ~/trac/trac.htpasswd perrygeo

# Set up the developer group
trac-admin ~/trac permission add developer WIKI_ADMIN
trac-admin ~/trac permission add developer REPORT_ADMIN
trac-admin ~/trac permission add developer TICKET_MODIFY
trac-admin ~/trac permission add perrygeo developer

vi /etc/apache2/sites-enabled/000-default
ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi
<Location "/trac">
SetEnv TRAC_ENV "/home/perrygeo/trac"
</Location>

<Location "/trac/login">
AuthType Basic
AuthName "Trac"
AuthUserFile /home/perrygeo/trac/trac.htpasswd
Require valid-user
</Location>

#restart apache & access it at:
http://192.168.1.46/trac

Geoserver (alternate WMS/WFS server)

cd /opt
sudo chown -R /opt perrygeo
wget http://easynews.dl.sourceforge.net/sourceforge/geoserver/geoserver-1.3.1beta-bin.tar.gz
tar -xzvf geoserver-1.3.1beta-bin.tar.gz

Now you have to download the JDK from http://java.sun.com/j2se/. After swimming through the alphabet soup that it the java marketing department, you should have a file called j2eesdk-1_4_03-linux.bin . Make sure you've got a quarter-GB for installation!

chmod +x j2eesdk-1_4_03-linux.bin
sudo apt-get install libstdc++2.10-glibc2.2
./j2eesdk-1_4_03-linux.bin
-----
/opt/java
admin:javapass
Administration Port [4848]
HTTP Port [2067]
HTTPS Port [8181]
-----

This reports some info that may be useful someday if we want to set up a j2ee admin server. OPTIONAL.

Next Steps:
1. Access the About Application Server PE 8 welcome page at:
file:///opt/java/docs/about.html
2. Start the Application Server by executing:
/opt/java/bin/asadmin start-domain domain1
3. Start the Admin Console:
http://localhost:4848
4. Access sample applications:
http://localhost:2067/samples/index.html

set up the environment in you bash shell then source .bashrc

PATH=/opt/java/jdk/jre/bin:$PATH

now set up geoserver's server:

cd /opt/geoserver
vi documents/jetty.xml
----
<Set name="Port"><SystemProperty name="GEOSERVER_PORT" default="8090"/></Set>
----

vi bin/startup.sh
----
JAVA_HOME=/opt/java/jdk/jre
GEOSERVER_HOME=/opt/geoserver
----
# Add same lines to bin/shutdown.sh

Now run /opt/geoserver/bin/startup.sh and access the server at http://192.168.1.46:8090/geoserver. It will take some time to configure itself after which you should see the welcome screen.

Warning Geoserver's security model sucks. In fact it is non existent. If you set up a vector layer to be served by WFS, ANYONE who knows the URL has full read/write access to you GIS data. I would not consider geoserver for production for this reason alone.

Finally, for completeness sake, set up a init.d script

sudo chown -R www-data geoserver/
sudo chmod -R 775 geoserver/
sudo vi /etc/init.d/geoserver
----
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions
case "$1" in start) log_begin_msg "Starting geoserver ..." su www-data -c "/opt/geoserver/bin/startup.sh" log_end_msg $? ;; stop) log_begin_msg "Stoping geoserver ..." su www-data -c "/opt/geoserver/bin/shutdown.sh" log_end_msg $? ;; restart|force-reload) log_begin_msg "Restarting geoserver ..." su www-data -c "/opt/geoserver/bin/startup.sh" su www-data -c "/opt/geoserver/bin/shutdown.sh" log_end_msg $? ;; *) echo "Usage: /etc/init.d/geoserver {start|stop|restart}" exit 1 ;; esac exit 0 ----
sudo chmod +x /etc/init.d/geoserver


PHP PgAdmin

sudo apt-get install phppgadmin
cp -r phpPgAdmin-4.0.1/ /opt/phppgadmin
sudo vi /etc/apache2/sites-enabled/000-default
---
Alias /phppgadmin/ "/opt/phppgadmin/"
<Directory "/opt/phppgadmin/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
AuthType Basic
AuthName "PhpPgAdmin"
AuthUserFile /opt/phppgadmin/.htpasswd
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
---
edit /opt/phpgadmin/conf/config.inc.php
# point to proper paths etc

sudo chown -R www-data /opt/phppgadmin/
sudo htpasswd -c /opt/phppgadmin/.htpasswd perrygeo
# give password

# Access at http://host/phppgadmin/


Metadata management & data portals

Geonetwork

cd /opt
wget http://easynews.dl.sourceforge.net/sourceforge/geonetwork/geonetwork-intermap-2.0.2-install.jar

# Needs X11 to run the installer :-(
sudo apt-get install x-window-system-core x11-common xterm
sudo dpkg-reconfigure x11-common
# allow Anybody, probably not safe or necessary
sudo xauth -b quit
sudo ln -s /usr/X11R6/bin /usr/bin/X11
cd /opt/java/jdk/jre/lib/i386
sudo chmod +x awt_robot

# relogin wih ssh -X
cd /opt
java -jar geonetwork-intermap-2.0.2-install.jar
# run through the graphic installer
/opt/geonetwork/bin/start-geonetwork.sh
# access at http://192.168.1.46:8100/geonetwork/

To do: create inti.d script (geonetwork)

MediaWiki

cd ~/www
wget http://easynews.dl.sourceforge.net/sourceforge/wikipedia/mediawiki-1.6.5.tar.gz
tar -xzvf mediawiki-1.6.5.tar.gz
mv mediawiki-1.6.5 wiki
cd wiki
chmod a+w config
# run through web setup (linked from http://host/wiki)
# create user "wikiuser" to own the new db
cp config/LocalSettings.php .
#access at http://host/wiki


Moodle

Moodle is great software for setting up a online learning environment; complete courses may be taught through moodle.

cd ~/www
wget http://download.moodle.org/download.php/stable15/moodle-latest-15.tgz
tar -xzvf moodle-latest-15.tgz
cd moodle
mkdir ~/.moodledata
sudo chown www-data ~/.moodledata
sudo chmod 775 ~/.moodledata
mysql -p -u root
# > create database moodle
# > GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'moodlepass' WITH GRANT OPTION;
# Go through installer at http://host/moodle/


Still to do


Examples using these software packages to work with real spatial data is documented at  Web Mapping Setup


System Admin scripts


cron tasks / scripts to automate

  • postgres vacuum
  • postgres backups
  • filesystem backups
  • logfile rotation
  • tmp directory cleanup
  • Ruby, Perl mapscript


network filesystem (Samba and/or NFS)


Metacat





Built with Plone