umn-mapserver with postgis on SuSE Linux

- using Mapbender as WMS Client Suite

(August/September 2003)

This document should be read as a step-by-step how-to and does not claim completeness.

For this How-To UMN-mapserver versions 3.6.5, 3.6.6 and 4.0 were tested. '3' refers to '3.6.x' and '4' refers to '4.0.x'.

Additional Information related to the installation of umn-mapserver on SuSE Linux 8.0 can be found here:

http://mapserver.gis.umn.edu/cgi-bin/wilma_hiliter/mapserver-users/0208/msg00285.html

Detailed information how to install mapbender WMS Client Suite can be found on http://www.mapbender.org.

I. Required Software

SuSE Linux 8.1, 8.2, 9 Professional, SuSE Linux Enterprise Server 8 / United Linux 1.0

The rpm-packages listed here are chosen from SuSE 8.1. SLEP/United Linux 1.0 ist based on SuSE Professional 8.1. There are slightly newer packages available with SuSE 8.2 and there are really newer packages available with SuSE 9.

Because of missing rpm-packages, it is necessary to install a lot of software via compling source code. In this case dependencies have to be carefully checked, before doing so.

Available rpm packages

ftp://ftp.suse.com/pub/suse/i386/ or

http://www.rpmfind.net

General software packages

Apache-1.3.26	http://httpd.apache.org/

postgresql-7.2.2	http://www.postgresql.org

mysql-3.23.52	http://www.mysql.org

mysql-client-3.23.52

mysql-devel-3.23.52

required libraries for umn-mapserver

http://mapserver.gis.umn.edu/doc36/unix-install-howto.html

http://mapserver.gis.umn.edu/doc40/unix-install-howto.html

curl-7.10.2 (SuSE 8.2)	http://curl.haxx.se/libcurl/	(ms 4)

curl-devel-7.10.2 (SuSE 8.2)

gd-1.8.4	http://www.boutell.com/gd/	(ms 3)

gd-devel-1.8.4

gd-2.0.15 (SuSE 9)	(ms 3/4)

gd-devel- 2.0.15 (SuSE 9)

libxml2-2.4.23	http://xmlsoft.org/

libxml2-devel-2.4.23

yacc-91.7.30

optional libraries for umn-mapserver

freetype2-2.0.9	http://www.freetype.org/

freetype2-devel-2.0.9

libjpeg-6.2.0	http://www.ijg.org/

libtiff-3.5.7	http://www.libtiff.org/

libpng-1.2.4	http://www.libpng.org/pub/png/

libpng-devel-1.2.4

Not available as rpm package:

General software packages

postgis 0.7.4 or higher	http://postgis.refractions.net

mapserver 3.6.5 or higher	http://mapserver.gis.umn.edu

php 4.3.3	http://www.php.net

required libraries for umn-mapserver

gdal 1.1.9	http://www.remotesensing.org/gdal/	(ms 3)

gd 2.0.12	http://www.boutell.com/gd/	(ms 3/4)

proj-4.4.5	http://www.remotesensing.org/proj/

libwww-5.4.0	http://www.w3.org/Library/	(ms 3)

libiconv-1.9.1	http://www.gnu.org/software/libiconv/ (ms 4)

Optional libraries for umn-mapserver

pdflib 4 or 5	http://www.PDFlib.com

Other optional libraries

LibGeoTIFF:	http://www.remotesensing.org/geotiff/geotiff.html

MPATROL:	http://www.cbmamiga.demon.co.uk/mpatrol/

Oracle Spatial Client Librairies:

These librairies are provided with your Oracle product, and used to interface with an Oracle Spatial warehouse.

SDE Client Librairies:

These libraries are provided with ESRI's Spatial Data Warehouse ArcSDE (Optional).

II. SuSE systems installation

It is recommended to change the default partition suggestions.

III. Software installation

General instructions

Yast2

Yast2 is a graphical frontend bases on rpm-packages which is able to solve dependency confilicts.

rpm

Rpm-packages can be installed within a shell of course, too.

rpm –i URL (i.g. rpm -i ftp://ftp.suse.com/pub/suse/…/mod_php4-4.3.1-52.i586.rpm)

rpm –i .rpm (i.g. rpm –i /tmp/mod_php4-4.3.1-52.i586.rpm)

directly from source

The sources can be downloaded from the websites listed in section I. Required Software.

First the archive has to be extracted:

# tar –xzf filename.tgz or

# gzip -d –c filename.tgz | tar xvf –

After extraction the configure skript can be executed. This skript builds a system-specific makefile.

Change into the folder which was just created by the extraction-process and type:

./configure [optional: --with-option / usually –h or –help prints out all available options]

Then the source code can be built via ‘make’ after finishing, installed via ‘make install’

PostgreSQL

Installation instructions:

Via Yast or rpm -i postgresql-7.X.X-XX.i586.rpm

rpm -i postgresql-7.X.X.-XX.src.rpm

The source code is needed for building postgis against the PostgreSQL source tree later on. It is usually installed into /usr/src/packages/SOURCES/ and needs to be extracted.

# tar -xjf postgresql-7.2.2.tar.bz2

# cd postgresql-7.2.2/

# ./configure

# make

If the ./configure complains, that readline isn't installed, configure –wihtout-readline!

To start postgresql manuall just type “/etc/init.d/postgresql start”. To start postgresql on boot, configure the appropriate part within yast2.

To have pgsql accepting Internet connections /var/lib/pgsql/data/postgresql.conf must be edited. ‘tcpip_socket=false’ must be uncommented and set to true. It is also required to add a line to the pg_hba.conf, which contains the list of allowed hosts.

Creating the first db

# createdb test

Opening the db with psql shell client

# psql test

MySQL

Instead of MySQL 4 it is also possible to run MySQL 3.23

Installation Instructions:

Via Yast or rpm -i mysql-3.23.XX-XX.i586.rpm

Via Yast or rpm -i mysql-devel-3.23.XX-XX.i586.rpm*

* required for building php --with-mysql

Apache

For this How-To the versions available within the SuSE-package were tested. It is recommended to use the latest release.

Installation instructions:

Via Yast or rpm -i apache-1.3.XX-XX.i586.rpm

PHP4

Basically it is recommended to install php4 as a apache module for security reasons. However if umn-mapserver needs to be compiled with php to support phpMapScript, then php needs to be compiled as a cgi. The usage of 'suexec' or 'suphp' (www.suphp.org) for security reasons should be taken into account (See http://www.php.net/manual/en/security.cgi-bin.php for more information on this security issue)!

- Required opitions for php4 to choose

postgressql Support

mysql support (required by mapbender)

dbase support

domxml support

gd2 support

curl support (mandatory only for ms 4!)

zlib support

xml support

freetype support

jpeg support

png support

tiff support

- PHP4 Installation procedure

1. Without phpMapScript support, with mapbender

As mod_php is not built with domxml, it is required to build php manually. Skip this section for the moment.

Installation instructions:

Via Yast or rpm -i mod_php4-4.2.2-X.i586.rpm

Apache needs to be restarted in order to load the php4-module. That should happen automatically after the installation. If not, this can be accomplished either by typing '/etc/init.d/apache restart' or by typing 'apachectl graceful'

2. With phpMapScript support, with or without mapbender

PHP4 must explicitely be compiled as a cgi and with the ‘--with-system-regex’ option (default: --with-regex=php) , if phpMapScript support is required. Version 4.1 of umn-mapserver will allow to have php4 compiled as a apache module running with phpMapScript.

More information:

http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0208/msg00354.html

http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPMapScript

http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPMapScriptCGI

Installation instructions:

The configure options below require the following package installed, too:

Via Yast or rpm -i flex-2.5.4a-38.rpm

Configure options for php:

# ./configure --prefix=/usr/share --datadir=/usr/share/php --bindir=/usr/bin --libdir=/usr/share --includedir=/usr/include --with-_lib=lib --with-config-file-path=/etc --with-exec-dir=/usr/lib/php/bin --disable-debug --enable-bcmath --enable-calendar --enable-ctype --enable-dbase --enable-exif --enable-filepro --enable-force-cgi-redirect --enable-ftp --enable-gd-imgstrttf --enable-gd-native-ttf --enable-inline-optimization --enable-magic-quotes --enable-mbstr-enc-trans --enable-mbstring --enable-mbregex --enable-memory-limit --enable-safe-mode --enable-shmop --enable-sigchild --enable-sysvsem --enable-sysvshm --enable-track-vars --enable-trans-sid --enable-versioning --enable-wddx --enable-yp --with-bz2 --with-dom=/usr/include/libxml2 --with-gettext --with-jpeg-dir=/usr --with-mysql=/usr --with-pgsql=/usr --with-png-dir=/usr --with-tiff-dir=/usr --with-ttf --with-freetype-dir=yes --with-xml --with-zlib=yes --with-gd --with-curl=/usr/local --with-iconv --with-regex=system

It seems to be necessary to copy “/path/to/src-code/php.ini-dist” to /etc/php.ini!

After finishing the installation, the 'php4' binary (/data/src/php-4.3.3/sapi/cgi), must be copied into the server's ‘cgi-bin’ directory (SuSE default: /srv/www/cgi-bin) and the following lines have to be added to the apache configuration-file httpd.conf at the appropriate location:

ScriptAlias /cgi-bin/ /srv/www/cgi-bin

AddType application/x-httpd-php .php

Action application/x-httpd-php /cgi-bin/php

There are similar lines in the httpd.conf. So, theses lines just have to be added below the existing ScriptAlias and AddType lines (Action and AddType belong together).

- Final Steps

A directory alias for apache has to be configured to allow web access to the “sessions”-directory of umn-mapserver. For instance:

Alias /umn/ "/data/umn/umn-www"

<Directory "/data/umn/umn-www">

Options All

AllowOverride None

Order allow,deny

Allow from all

</Directory>

Libraries

http://mapserver.gis.umn.edu/doc36/unix-install-howto.html#obtain

http://mapserver.gis.umn.edu/doc40/unix-install-howto.html#obtain

Freetype2-2.1.4

Installation instructions:

Via Yast or rpm -i freetype-devel-2.1.2-X.i386.rpm

libxml2

Installation instructions:

Via Yast or rpm -i libxml2-2.4.23-XXX.i586.rpm

Via Yast or rpm -i libxml2-devel-2.4.23-XXX.i586.rpm*

* required for building php --with-libxml

jpeg-6b_1

Installation instructions:

Via Yast or rpm -i libjpeg-6b-XX.i386.rpm

png-1.2.5

Installation instructions:

Via Yast or rpm -i libpng-1.2.4-XX.i586.rpm

Via Yast or rpm -i libpng-devel-1.2.4-XX.i586.rpm

tiff-3.5.7

Installation instructions:

Via Yast or rpm -i libtiff-devel-3.5.7-7.i386.rpm

Yacc-91

Installation instruction:

Via Yast or rpm -i yacc-91.7.30-XXX.i586.rpm

libiconv-1.9.1 (only mapserver 4, seems to be needed by latest gd2-version)

Installation instructions:

No rpm-package available. Installation via source code compilation:

# ./configure

# make

# make install

# ldconfig

proj-4.4.5

Installation instructions:

No rpm-package available.

mapserver needs an epsg-file in capitel letters. The easies way is to maka a symbolic link in /usr/local/share/proj:

ln –s epsg EPSG

gdal-1.1.9

Installation instructions:

No rpm-package available. Requires g++! Installation via source code compilation:

# ./configure

# make

# make install

# ldconfig

If UMN-MapServer failes to run with a appropriate gdal error-message, the following needs to changed:

# vi /etc/ld.so.conf (add /usr/local/lib)

# ldconfig –v (check for entry)

curl-7.10.x (only mapserver 4, replaces libwww)

Installation instructions:

Via Yast or rpm -i curl-7.10.2-XX.i586.rpm

Via Yast or rpm -i curl-devel-7.10.2-XX.i586.rpm

libwww-5.4.0 (only mapserver 3)

Installation instructions:

Via Yast or rpm -i w3c-libwww-devel-5.4.0-X.i386.rpm

gd (for mapserver 3)

Installation instructions:

Via Yast or rpm -i gd-1.8.4-XXX.i586.rpm (only ms 3)

Via Yast or rpm -i gd-devel-1.8.4-XXX.i586.rpm (only ms 3)

SuSE 8.1 ships with gd-1.8.4 and even SuSE 8.2 only ships with gd-2.0.11. For UMN-MapServer 4.0.x at least gd-2.0.12 is required.

gd2 (for mapserver 4)

Installation instructions for SuSE 9

Via Yast or rpm -i gd-2.0.15.rpm

Via Yast or rpm -i gd-2.0.15-devel.rpm

Installation instructions:

No rpm-package available. Installation via source code compilation:

# ./configure

# make

# make install

# ldconfig

postgis 0.7.5

Postgis needs to be uncompressed and untared the archive in the "contrib" directory of the PostgreSQL source tree.

# cd /sourc-tree-of/postgresql-7.X.X/contrib

# gzip -d -c postgis-0.7.5.tar.gz | tar xvf -

# mv postgis-0.7.5 postgis

The Makefile has to be edited. “USE_PROJ=0” needs to be changed to “..=1”.

# make

# make install

Two libraries have to be moved. Usually /usr/lib/postgresql. Check this via pg_config –pkglibdir in the shell. Use the path pg_config shows.

# cp /usr/local/pgsql/lib/libpostgis.a /usr/lib/postgresql

# cp /usr/local/pgsql/lib/libpostgis.so.0.7 /usr/lib/postgresql

and finally you have to create two symbolic links

# ln –s libpostgis.so.0.7 libpostgis.so

# ln –s libpostgis.so.0.7 libpostgis.so.0

The following is necessary to add postgis support into a new or existing, but empty postgressql database (see http://postgis.refractions.net/docs/x83.html)

It is necessary to do the following as a know database user. On debian systems the pgsql-User is called postgres.

# su PG-SQL_USER

# createdb mydb (pgSQL-command to create a new database)

# createlang plpgsql mydb (there’ll be no output)

# psql -d mydb -f /usr/local/pgsql/share/contrib/postgis.sql (psql the SQL console)

# psql -d mydb -f /usr/local/pgsql/share/contrib/spatial_ref_sys.sql

Do the following to verify the postgis installation (see http://postgis.refractions.net/docs/c191.html)

CREATE TABLE gtest ( ID int4, NAME varchar(20) );

SELECT AddGeometryColumn('mydb','gtest','geom',-1,'LINESTRING',2);

INSERT INTO gtest (ID, NAME, GEOM) VALUES (1, 'First Geometry',

GeometryFromText('LINESTRING(2 3,4 5,6 5,7 8)', -1));

Check whether you can query this table:

SELECT id, name, AsText(geom) AS geom FROM gtest;

id | name | geom

----+----------------+-----------------------------

1 | First Geometry |	LINESTRING(2 3,4 5,6 5,7 8)

(1 row)

The following output can be see after executing postgis.sql. This is not an error!

> psql -d test2 -f /root/postgresql/postgresql-7.3.2/contrib/postgis-0.7.4/postgis.sql > /tmp/output.txt

psql:/root/postgresql/postgresql-7.3.2/contrib/postgis-0.7.4/postgis.sql:18: NOTICE: ProcedureCreate: type histogram2d is not yet defined

psql:/root/postgresql/postgresql-7.3.2/contrib/postgis-0.7.4/postgis.sql:23: NOTICE: Argument type "histogram2d" is only a shell

.

.

psql:/root/postgresql/postgresql-7.3.2/contrib/postgis-0.7.4/postgis.sql:154: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'spatial_ref_sys_pk

ey' for table 'spatial_ref_sys'

psql:/root/postgresql/postgresql-7.3.2/contrib/postgis-0.7.4/postgis.sql:174: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'geometry_columns_p

k' for table 'geometry_columns'

UMN-MapServer

General Instructions

The value for MS_MAXSYMBOLS in mapsymbol.h can be changed to a higher one, e.g. “# define MS_MAXSYMBOLS 250“.

To configure mapserver create a little script and insert the following. Don't forget to set the executable bit (chmod u+x <skriptname>)!

If compilation of mapserver fails (first occured on SuSE 8.2) with an error regarding gdal (e.g. cannot find gdal-config), then supply the full path to gdal-config after –with-ogr!

It seems that flex, bison and openssl-devel are also required!

The value of --with-php has to be the path to the source tree of php.

UMN-MapServer 3.6.5 / 3.6.6

Edit map.h and change the default value for MS_MAXCLASSES from 64 to a higher value if required:

#define MS_MAXCLASSES 250

#!/bin/sh

./configure	--with-gd=/usr \

--with-gdal \

--with-ogr[=/usr/loacal/bin/gdal-config] \

--with-proj=/usr/local \

--with-jpeg \

--with-png \

--with-tiff \

--with-zlib \

--with-freetype \

--with-wmsclient \

--with-php=/data/src/php-4.3.3 \

--with-postgis

Obviously it is not necessary to supply the graphics libraries, so the following seems to be enough:

#!/bin/sh

./configure	--with-gd=/usr \

--with-gdal \

--with-ogr \

--with-proj=/usr/local \

--with-wmsclient \

--with-php=/data/src/php-4.3.3 \

--with-postgis

Before compiling mapserver, the phpMapScript makefile has to be edited (../mapserversource/mapscripbt/php3/Makefile).

Change:

CC= cc to CC= gcc

LD= cc -Wl -Wl, to LD= gcc -Wl -Wl,-share

and

-I$(PHP_SRC_DIR)/dl to -I$(PHP_SRC_DIR)/ext

That’s an excerpt of the part of the makefile, which has to be edited:

CC = gcc -I. -I.. -DPIC -fpic

LD = gcc -Wl -Wl,-share

CFLAGS = -O2 -Wall -DCOMPILE_DL=1 -DPHP4

RUNPATHS= -R/usr/local/lib -R/usr/home/src/mapserver-3.6.5

#

# Set PHP_SRC_DIR to point to the root of the PHP source tree

#

PHP_SRC_DIR = /usr/ports/www/mod_php4/work/php-4.3.1

PHP_INC = -I$(PHP_SRC_DIR) -I$(PHP_SRC_DIR)/ext -I$(PHP_SRC_DIR)/main \

-I$(PHP_SRC_DIR)/Zend -I$(PHP_SRC_DIR)/include \

-I$(PHP_SRC_DIR)/TSRM

Because there are incompatibilities between mapserver 3.6 and pgsql 7.3.2 a new mappostgis.c has to be used. See http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0304/msg00305.html

Finally compile the code with make (DO NOT make install!!) and copy the mapserv binary to /srv/www/cgi-bin!

UMN-MapServer 4.0

#!/bin/sh

./configure	--with-gd \

--with-gdal \

--with-ogr \

--with-proj \

--with-jpeg \

--with-png \

--with-tiff \

--with-libiconv=/usr/local \

--with-zlib \

--with-curl \

--with-php=/data/src/php-4.3.3 \

--with-freetype \

--with-wmsclient \

--with-wfs \

--with-wfsclient \

--with-postgis \

Obviously it is not necessary to supply the graphics libraries, so the following seems to be enough:

#!/bin/sh

./configure	--with-libiconv=/usr/local \

--with-proj \

--with-wmsclient \

--with-wfs \

--with-wfsclient \

--with-postgis \

--with-ogr \

--with-gdal

Finally compile the code with make (DO NOT make install!!) and copy the mapserv binary to /srv/www/cgi-bin!

Remarks:

It seems impossible to compile mapserver 4 and 3.6.6 with an installed gd and gd2.

--> mapserver 4 Kompilierungsfehler (mapgd.o):

gd-1.8-4 via Yast

gd-2.0.15 manuell

gd-1.8.4 deinstallieren!!

--> Problem mod_php4 hängt davon ab (/usr/lib/libgd.so.4, libgd.so, libgd.so.4.0.0

Nach der Installation sind seltsamerweise an anderem Ort (/usr/local/lib/) und mit niedrigerer Bezeichnung

libgd.so.2.0.0

libgd.so.2 -> libgd.so.2.0.0

libgd.so -> libgd.so.2.0.0 installiert

UMN-MapServer on SuSE

Benjain Thelen

2003-07-31T16:02:00

Benjamin Thelen