(July 2005)


This How-To describes the required steps to have a UMN-MapServer 4.4.1 with PostGIS 1.0.2 support on FreeBSD 5.4 running, as well as using Mapbender as a WMS Client.


There is also an older version for freeBSd 4.11 - if you need this, please contact thelen [at] ccgis.de or adams [at] terrestris.de Ben Thelen, CCGIS GbR Bonn (Geo-Consortium) Till Adams, terrestris GbR Bonn (Geo-Consortium)


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


I. Required Software

Available FreeBSD Ports:

http://www.freebsd.org/ports/index.html

Basic

apache-1.3.33 (Category www) http://httpd.apache.org/

mod_php5-5.0.4 (Category www) http://www.php.net

postgresql-server-8.0.3 (Category databases)http://www.postgresql.org

mysql-server-4.1.13 (Category databases) http://www.mysql.org

mapserver-4.4.1 (Category graphics) http://mapserver.gis.umn.edu

postgis-1.0.2 (Category databases) http://postgis.refractions.net

Libraries

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


gd-2.0.33 (Category graphics) http://www.boutell.com/gd/

proj-4.4.9 (Category graphics) http://www.remotesensing.org/proj/

geos-2.0.1 (Category graphics) http://geos.refractions.net/

curl-7.14.0 (Category ftp) http://curl.haxx.se/libcurl/

libiconv-1.9.2 (Category converters) http://www.gnu.org/software/libiconv/

libxml2-2.6.8 (Category textproc) http://xmlsoft.org/ (Mapbender)

gdal-1.2.1 (Category graphics) http://www.remotesensing.org/gdal/

freetype2-2.1.10 (Category print) http://www.freetype.org/

jpeg-6b (Category graphics) http://www.ijg.org/

tiff-3.7.3 (Category graphics) http://www.libtiff.org/

png-1.2.8 (Category graphics) http://www.libpng.org/pub/png/








II. Software installation

General instructions

For FreeBSD systems installation and maintanence, please read the excellent online handbook (http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/index.html). I'll just give some basic hints, as there is enough (detailed and better) documentation available.


To build a webserver, have the tools at hand to build a custom kernel and to be able to apply security patches, the installation set called Developer is the best choice to start the systems installation with.

Having chosen the installation set, one is asked whether to install the ports-collection. The name port means in FreeBSD nomenclature the name for a standard software package (to be more accurate: a source archive) combined with FreeBSD specific patches. It is highly recommended to do so, as the ports-collection offers an easy and flexible way of software installation and maintenance. Dependencies are taken into consideration and software updates are made comfortable. The port-collection is installed into /usr/ports. A tree structure is built up, which shows about 60 categories of software. To install software, one has to change into the directory called like the software one wishes to install, underneath the appropriate category and type make install clean && pkgdb -Fa. First, the compressed archive with the original source code is downloaded, after extraction, the FreeBSD specific patches are applied and finally the software will be compiled and installed.


To manage software installation and maintanence via ports-collection, two ports (“software packages”) have to be installed. This is net/cvsup-without-gui and sysutils/portupgrade. sysutils respectively net points to the category in which the specified software can be found.

As a first step after systems installation, it is advisable to update the ports-collection, to have up-to-date software available. This update actually is a cvs (concurrent version system) synchronization, thus this update process is a synchronisation via cvs. Two configuration files are required, one for the port-collection and a second for the FreeBSD sources. The first example, synchronizes the ports and the second synchronizes the FreeBSD sources, but only with security patches ( this is what 'tag=RELENG_5_4' is for).



# synchronize ports-tree

*default host=cvsup2.de.FreeBSD.org

*default prefix=/usr

*default release=cvs tag=.

*default delete use-rel-suffix

ports-all

doc-all



# synchronize FreeBSD sources

*default host=cvsup2.de.FreeBSD.org

*default prefix=/usr

*default release=cvs tag=RELENG_5_4

*default delete use-rel-suffix

src



Choose a server near your location! A complete list can be found at the end of Appendix A.5.5 CVSup File Collections of the english handbook:

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvsup.html

There is also a list of the cvs branch tags (e.g. RELENG_5_4)

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvs-tags.html


The synchronisation progress will be started by typing the following in in a shell:

cd /usr/ports && cvsup /path-to-/supfile && make fetchindex


The last command fetches a file which can be seen as a table of contents of the ports-collection.


Now the latest software can be installed. To synchronize all installed software with the freshend ports-collection type portupgrade -arR.. Portupgrade executes pkgdb -Fa automatically.




Further important commands:


pkg_info [|grep package-name/part of package name] lists [all] installed packages

portversion –v checks whether all installed packages are up to date with the ports collection (but requires an up-to-date index - see above).

portupgrade <portname> upgrade a specific portname

portupgrade -arR upgrade all installed packages recursively

pkgdb –Fa should be executed to update the ports database properly after every installation via make install clean (a single sofware installation)

portsclean -C to clean the work directories within the ports-collection


Starting the installation

Keep in mind that some packages can already be installed on the system as a result of a dependency. For example, if you install the apache php modul, apache webserver itself will be installed as a consequence of the given dependency, too. Another example would be the library gdal, which installes several libraries, like jpeg, tiff, png and freetype2 automatically. This, of course, only works if a software installation system like the ports-collection is used.


The installation can easily be accomplished by opening one shell, changing to the given directory and typing make install clean. That's all.

Before you start, you have to set an environment varible, to activate GEOS support within PostGIS:

In csh shell:

# setenv LDFLAGS -lstdc++

In sh or bash shell:

# export LDFLAGS=-lstdc++




The following ports are installed as dependency of one of the above installed ports. There should be no necessity to install them seperately.


Last Steps


postgreSQL

The standard partition /usr/ is in some circumstances not big enough to hold huge databases. Additionally it is advisable to separate the data. The easiest way to accomplish both is to move the data to another partition or better another harddrive and create a symbolic link.


# ln -s /usr/local/pgsql /data/pgsql


To start the PostgreSQL DBMS at boot time, add to /etc/rc.conf 'postgresql_enable="YES"'. To initialize the DBMS type:


# /usr/local/etc/rc.d/010.pgsql.sh initdb



PHP5


Add AddType application/x-httpd-php .php to httpd.conf.



UMN MapServer

A first test with /usr/local/www/cgi-bin/mapserv -v should look like this:


FreeBSD:~ # /usr/local/www/cgi-bin/mapserv -v

MapServer version 4.4.1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE


If you type http://hostname/cgi-bin/mapserv within your web browser, you should see the following:


No query information to decode. QUERY_STRING is set, but empty






For the advanced user, compiling UMN-MapServer by hand

Extract the tarball-archive via tar -xzvf mapserver-4.6.0.tar.gz.

First the configure script needs to be executed. Change to the location, where you've extracted the source code and type the following in a shell:


./configure --with-xpm=/usr/X11R6/lib \

--with-gd \

--with-gdal \

--without-eppl \

--with-ogr \

--with-proj=/usr/local \

--with-jpeg=/usr/local \

--without-pdf \

--with-png=/usr/local \

--without-png \

--with-tiff=/usr/local \

--without-tiff \

--with-libiconv=/usr/local \

--with-zlib \

--with-curl \

--with-freetype \

--with-wmsclient \

--with-wcs \

--with-wfs \

--with-wfsclient \

--with-postgis



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