(October 2004, slightly revise March 2005)
This How-To describes the required installation steps to have a UMN-MapServer 4 with PostGIS support on debian GNU/Linux running, and using Mapbender as a WMS client.
There is absolutely no warranty for this, but for us it wokrs in 95%. Feel free to alter the text or give us feedback, Till Adams, terrestris GbR Bonn (Geo-Consortium) ben Thelen, CCGIS GbR Bonn (Geo-Consortium)
Detailed information how to install mapbender WMS Client Suite can be found on http://www.mapbender.org.
Operating system: debian GNU/Linux 3 (woody) or 3.1 (sarge)
If you have a Debian Woody and want to update this to Sarge, the new stable release, do the following:
#apt-get update
#apt-get upgrade
#apt-get dist-upgrade
Ready. After this ensure to de-comment the unstable sources from your sources.list, which is in /etc/apt/sources.list. After doing this all the (sarge) keywords can be ignored.
Running woody requires the installation of many backports (http://www.backports.org/) or packages taken from sarge. Backports are packages which don't require newer dependencies. Packages taken frome sarge will usually install many dependent newer packages.
It is specified if it is recommended or even necessary not to install a package from woody! Because of developmen, version numbers, especially within sarge, are likely to differ from month to month, even from day to day.
Available debian packages
http://www.debian.org/distrib/packages
Apache 1.3.26 http://httpd.apache.org/
libapache-mod-php4 4.3 (sarge) http://www.php.net
php4-cgi 4.3 (sarge)
+ following modules:
php4-pgsql, php4-mysql, php4-curl, php4-gd2
postgresql-dev-7.4 (sarge) http://www.postgresql.org
postgresql-8.0-dev (testing)
mysql-server 4.0 (sarge) http://www.mysql.org
bzip2 Extracting source code
unzip Extracting source code
g++ Compiling source code
make Compiling source code
http://mapserver.gis.umn.edu/doc36/unix-install-howto.html
http://mapserver.gis.umn.edu/doc40/unix-install-howto.html
bison-1.875 (sarge) (MapServer > 4.0)
flex
libgd2-xpm-dev (sarge) http://www.boutell.com/gd/
proj 4.4.9 (sarge) http://www.remotesensing.org/proj/
libcurl2-dev (sarge) http://curl.haxx.se/libcurl/
libwww-dev http://www.w3.org/Library (Only MS-3)
libiconv-hook-dev (sarge) http://www.gnu.org/software/libiconv/
libgdal1 (sarge) http://www.remotesensing.org/gdal/
gdal-bin (sarge)
libfreetype6-dev (sarge) http://www.freetype.org/
libjpeg62-dev (sarge) http://www.ijg.org/
libtiff4-dev (sarge) http://www.libtiff.org/
libpng12-dev (sarge) http://www.libpng.org/pub/png/
libgeos-dev (sarge) http://geos.refrations.net/
GEOS-2.0.1 http://geos.refractions.net/
or get the GEOS 2.1.1.2 directly from debian (libgeos-dev)
The -dev (developer) packages are required, in order to have the required header-files on the system for compiling UMN-MapServer. The main packages will be installed as a dependency at the same time.
PostGIS 0.9 / 1.0 http://postgis.refractions.net
UMN MapServer 4.x http://mapserver.gis.umn.edu
LibGeoTIFF: http://www.remotesensing.org/geotiff/geotiff.html
Oracle Spatial Client Libraries http://www.oracle.com
These libraries are provided with Oracle, and used to interface with an Oracle Spatial warehouse.
SDE Client Libraries http://www.esri.com
These libraries are provided with ESRI's Spatial Data Warehouse ArcSDE.
# apt-get install package-name (i.e. apt-get install apache)
# apt-get remove package-name (i.e. apt-get remove apache)
The list of sources, which apt requires are configured via apt-setup and then saved in '/etc/apt/sources.list'. The source can for example be CD/DVD or the internet. Installing via internet requires an active broadband internet connection - the faster the better.
Dependencies are taken into account and are installed at the same time.
To have access on non-stable sources /etc/apt/sources.list must be edited, as apt-setup just adds “stable” sources. See the example below.
Example of /etc/apt/sources.list:
deb http://ftp.tu-clausthal.de/pub/linux/debian/ stable main non-free contrib
deb-src http://ftp.tu-clausthal.de/pub/linux/debian/ stable main non-free contrib
deb http://ftp.de.debian.org/debian sarge main contrib non-free
deb-src http://ftp.de.debian.org/debian sarge main contrib non-free
deb http://http.us.debian.org/debian unstable main contrib non-free
deb-src http://http.us.debian.org/debian unstable main contrib non-free
deb http://security.debian.org/ stable/updates main contrib non-free
It is recommended to use the code-names:
stable = woody
sarge = sarge
unstable = sid
To install from a special brunch the following syntax is required:
apt-get install –t sarge packedge (not required when having a sarge-system running)
The sources can be downloaded from the above listed websites.
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–help prints out all available options]
Then the source code can be built via make after finishing ./configure and installed via make install. But of cource no dependencies are installed automatically and deinstallation routines ar rare!
To configure and build the software again it is required to clean the tree:
# rm config.cache && make clean
Following the instructions on how to use apt-get, it is just three commands which have to be executed to get all required debian packages installed.
# apt-get install g++ apache bison bzip2 unzip proj
# apt-get install -t sarge libapache-mod-php4 php4-pgsql php4-mysql php4-gd2 php4-curl postgresql-dev postgresql mysql-server libgdal1-dev libfreetype6-dev libjpeg62-dev libpng12-dev libcurl3-dev libgeos-dev
# apt-get source -t sarge dpkg-dev postgresql
dpkg-dev is required to unzip the debian-package.
Install either libapache-mod-php4 or php4-cgi! For more information, see below.
Before starting check /etc/hosts, if your hostname is correctly configured:
[your.ip.add.ress] [your.host.name]*
*Checkout with the command hostname.
PostgreSQL 7.2 is supported by UMN-MapServer, but version 7.3 is really recommended. PostGIS 0.8 supports PostgreSQL 7.4, PostGIS 0.9 supports PostgresSQL 8.0 and higher.
The source code is needed for building postgis against the PostgreSQL source tree later on. It is installed into the directory in which you're actually in and needs to be extracted. Aftwerwoods, the source code needs to be compiled.
# apt-get -b source postgresql
or
# dpkg-buildpackage -rfakeroot -uc -b
See http://www.debian.org/doc/manuals/apt-howto/ch-sourcehandling.en.html for more information.
To have PostgreSQL accepting Internet connections /var/lib/postgres/data/postgresql.conf needs to be edited. tcpip_socket=false or tcpip_socket=0 needs to be uncommented and set to true ( or '1' for pgsql 7.2.x). For PostgreSQL 8 this is not required, because the tcp/ip port is open by default!
It is also required to configure the pg_hba.conf, which contains the list of allowed hosts.
Default-Encoding war bei Installation
C
de_DE@euro
de_DE.iso885915@euro
Obwohl erst no2 und dann mit dpkg-reconfigure postgresql no3 ausgewählt wurde, war Encoding von template1 Latin9! Deshalb Datenbank manuell neu initialisiert:
/usr/lib/postgresql/bin/initdb -E SQL_ASCII -D /var/lib/postgres/data
MySQL is required by Mapbender-2 wms client suite.
The following needs to be added to /etc/my.cnf. “skip-innodb” just needs to be commented out.(normally the MySQL comes with inno-db by default).
#skip-innodb
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /var/lib/mysql/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/lib/mysql/
innodb_log_arch_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
It is recommended for security reasons to install PHP4 as an apache module. However if UMN-MapServer needs to be compiled with PHP4 to support phpMapScript, then PHP4 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)!
Install libapache-mod-php4.
Apache needs to be restarted in order to load the php4-module. That should happen automatically after installation. If not, this can be accomplished either by typing '/usr/local/etc/rc.d/apache restart' or by typing 'apachectl graceful'
Sometimes the debian installation does not automatically configure the apache httpd.conf in the correct manner. Check either if the line
LoadModule php4_module /usr/lib/apache/1.3/libphp4.so
is uncommended in the file '/etc/apache/conf/httpd.conf'
or if the entry 'Include /etc/apache/modules.conf'
is set and therein the above mentioned Module is enabled! After that restart apache.
Install php4-cgi.
PHP4 must explicitely be compiled as a cgi and with the ‘--with-system-regex’ option (default: --with-regex=php) , if phpMapScript support is required.
Further information:
http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0208/msg00354.html
http://old-mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPMapScript
http://old-mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPMapScriptCGI
As the php4-cgi package is compiled with '--with-regex=php' as default and '--with-regex=system' is required, the php4-cgi source code has to be downloaded and compiled. Afterwoods just the php-binary can be exchanged.
Usually three tgz-archives are downloaded. The source tree will be found within the folder php-4.x.x/, within the folder you’re actually in.
# ./configure --enable-force-cgi-redirect --with-regex=system --with-config-file-path=/etc/php4/cgi --prefix=/usr --with-pear=/usr/share/php --enable-memory-limit --enable-ctype --enable-sysvsem --enable-sysvshm --enable-track-vars --enable-trans-sid --enable-sockets --disable-static-disable-debug --disable-rpath --enable-calendar --enable-bcmath --with-iconv --enable-exif --enable-filepro --enable-ftp --with-gettext --enable-mbstring --enable-shmop --enable-wddx --with-expat-dir=/usr --enable-yp --with-zlib --with-xml=/usr --with-freetype-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-tiff-d
ir=/usr/lib --with-xpm-dir=/usr/lib --without-sysbase-ct --without-pgsql --without-mm --with-mysql --with-kerberos=/usr --with-openssl=/usr --with-exec-dir=/usr/lib/php4/libexec --enable-dbase --with-gd
# make
# mv /usr/lib/cgi-bin/php mv /usr/lib/cgi-bin/php.original
# cp /PATH/TO/SOURCE-TREE/php /usr/lib/cgi-bin
After finishing the installation, the PHP4 binary, has to be copied into the server's ‘cgi-bin’ directory (debian default: /usr/lib/cgi-bin) and the following lines have to be added to the apache configuration-file httpd.conf beneath AddType application/x-tar .tgz:
AddType application/x-httpd-php .php
Action application/x-httpd-php /cgi-bin/php
Also uncomment:
# LoadModule action_module /usr/lib/apache/1.3/mod_actions.so
A directory alias for apache has to be configured to allow web access to the directory, which is referenced in a map-file as “IMAGEURL.
Alias /umn/ "/data/umn/umn-www"
<Directory "/data/umn/umn-www">
Options All
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Apache needs to be restarted in order to load the changed httpd.conf. This can be accomplished by typing apachectl graceful.
UMN-MapServer expects an epsg-file in capitel letters. The easiest way is to create a symbolic link in /usr/local/share/proj:
ln –s epsg EPSG
This package was formerly required by UMN-MapServer. UMN-MapServer configure-Skript doesn't recognize this package. Alternatively the original source code can be downloaded, compiled and installed. But it seems, this library isn't required anymore.
Postgis needs to be uncompressed and untared the archive in the "contrib" directory of the PostgreSQL source tree. If Geos and/or Proj support is wanted, for Post5GIs 1.0 or above edit the Makefile.config and enable these by setting the value USE_PROJ ? = 0 to 1 and ensure, that the path to the PROJ_DIR is correct (# find / -name proj).
# cd /sourc-tree-of/postgresql-7.4.5/contrib
# gzip -d -c postgis-0.8.2.tar.gz | tar xvf -
Either the just created directory has to be renamed
# mv postgis-0.8.2 postgis
or the Makefile has to be edited. For projection support leave the value for USE_PROJ and additionally since PostGIS 0.8 for geos support leave the value for USE_GEOS (Requires a geos-installation), otherwise change it to “0”.
# cd postgis
# make
# make install
The file postgis.sql uses the variable $libdir. This variable contains the path to the PostGIS library. Some times it contains a wrong value and executing postgis.sql fails.
A workaround is to create a symlink in the directory where the library is expected – type 'pg_config --pkglibdir'. This will usually show /usr/lib/postgresql/lib. To create the symlink, type the following:
# ln -s /usr/local/pgsql/lib/libpostgis.so.0.9 libpostgis.so.0.9
The following adds postgis support into a new or existing, but empty PostgreSQL database (see http://postgis.refractions.net/docs/x83.html)
It is necessary to do the following as a known database user. On debian systems the pgsql-User is called postgres. Either, you can su to the postgres user or add -Upostgres user to every pgsql-command.
# su PG-SQL_USER
# createdb mydb (pgSQL-command to create a new database)
# psql -d mydb -f /usr/local/pgsql/share/contrib/postgis.sql (psql the SQL console)
For PostGIS 1.0 or above:
# psql -d mydb -f /usr/local/pgsql/share/contrib/swpostgis.sql (psql the SQL console)
For all versions:
# psql -d mydb -f /usr/local/pgsql/share/contrib/spatial_ref_sys.sql
If PostgreSQL does not enable pgsql procedural language as a default, it is neccessary to enable via /usr/lib/postgresql/bin/createlang plpgsql <databasename>
The following output can be see after executing postgis.sql. This is not an error!
> psql -d test2 -f /root/postgresql/postgresql-7.4.2/contrib/postgis-0.8.1/postgis.sql > /tmp/output.txt
psql:/root/postgresql/postgresql-7.4.2/contrib/postgis-0.8.1/postgis.sql:18: NOTICE: ProcedureCreate: type histogram2d is not yet defined
psql:/root/postgresql/postgresql-7.4.2/contrib/postgis-0.8.1/postgis.sql:23: NOTICE: Argument type "histogram2d" is only a shell
.
.
psql:/root/postgresql/postgresql-7.4.2/contrib/postgis-0.8.1/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.4.2/contrib/postgis-0.8.1/postgis.sql:174: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'geometry_columns_p
k' for table 'geometry_columns'
To configure mapserver create a little script and insert the following. Don't forget to set the executable bit (chmod u+x <skriptname>)!
To support phpMapScript supply the as the value of --with-php the path to the source tree of PHP4 : --with-php=/usr/home/src/php4-4.3.9
There may be some restrictions due to number of symbols (mapsymbol.h) or number of classes, layers, imagesite (all in map.h), you may set them to other values in the source code befre compiling.
#!/bin/sh
./configure --with-gd \
--with-gdal \
--with-ogr \
--with-proj \
--with-jpeg=/usr/ \
--without-png \
--without-tiff \
--with-zlib \
--with-freetype \
--with-wmsclient \
--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.6
#
# Set PHP_SRC_DIR to point to the root of the PHP source tree
#
PHP_SRC_DIR = /usr/home/src/php-4.3.4
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 /usr/lib/cgi-bin!
#!/bin/sh
./configure --with-xpm=/usr/X11R6/lib \
--with-gd \
--with-gdal \
--with-ogr \
--with-proj=/usr \
--with-jpeg=/usr \
--without-png \
--without-tiff \
--with-freetype \
--with-curl=/usr \
--with-wmsclient \
--with-wms-server \
--with-wfs \
--with-wfsclient \
--with-httpd=/usr/sbin/apache \**
--with-postgis
* See notice “libiconv-hook-dev” on page 7.
** Apache seems not to be recognized automatically anymore. First try without this option.
Finally compile the code with make (DO NOT make install!!) and copy the mapserv binary to /usr/lib/cgi-bin!