= MapServer on Debian GNU/Linux = == MapServer Debian Package == !MapServer 4.0.1 is installable directly as a debian package via apt-get on Debian Woody (and above). The package can be installed by adding the following lines to your /etc/apt/sources.list file: * deb http://www.paulbaker.net/debian stable main * deb-src http://www.paulbaker.net/debian stable main !MapServer is available as three packages: * mapserver-cgi - The mapserv cgi program installed in /usr/lib/cgi-bin * mapserver-utils - The other miscellaneous programs compiled as part of !MapServer. * libmapscript-perl - Mapscript/Perl? module. To install them, issue into a root shell: apt-get install mapserver-cgi mapserver-utils libmapscript-perl or use your favorite package manager (aptitude, synaptic...). Running /usr/lib/cgi-bin/mapserv -v should return the following output: !MapServer version 4.0.1 OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_CLIENT INPUT=TIFF INPUT=EPPL7 INPUT=JPEG INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE As of 2004/07/21, a vanilla Debian Sarge installation will cause mapserv to fail with: mapserv: relocation error: /usr/lib/libgdal.so.1: undefined symbol: _ZTI13XMLEntityDecl? because of changes in the current libgdal1_1.2.0-1 package. The solution is to force the installation of the package in Paul's repository. Check the current version: http://www.paulbaker.net/debian/dists/stable/main/binary-i386/gdal/ feed it to apt-get, and flag it with hold so its not upgraded: apt-get install libgdal1=1.2+cvs.031111-1.0woody.1 echo libgdal1 hold | dpkg --set-selections As usual, apt will uninstall any previously installed libgdal1. == What's missing? == So what's missing? WFS-Server, Flash/Ming?, Mapscript for all other languages besides Perl, PostGIS, MyGIS?, SDE, Oracle, and PDF. If you need these features, either email the package maintainer, Paul Baker at mailto:pbaker@where2getit.com, and/or build !MapServer yourself following steps below. == Compiling MapServer for Debian == This description relates to pre-woody (Debian r2.x) releases. Many of the supporting libraries are now available as packages, and many of the steps described here are likely to be obsolete. === 0.1 Install Debian Woody base system === You'll want to read http://www.debian.org/releases/stable/installmanual for instructions on that. === 0.2 Compile kernel 2.4.18 so we have ext3 filesystems === === 0.3 Install useful packages === {{{ apt-get install sash # A statically link root shell for fixing fatal mistakes apt-get install sshd # Secure shell because telnet is bad. apt-get install dpkg-dev # Needed to use source packages }}} Stable version of tune2fs doesn't support ext3 journals, use testing version of the e2fsprogs package {{{ vi /etc/apt/sources.list; apt-get update # point apt at testing distro apt-get install e2fsprogs }}} Since writing this, I have left apt pointing to testing (woody) since most of the libraries are closer to what !MapServer wants compared to stable (2.2r6). === 0.4 Update filesystems to use ext3 === === 1.0 Installing support libraries needed for !MapServer === === 1.1 Proj4 (v4.4.3-1) === My working Mapserver 3.5 box uses a compiled 4.4.3-2, but I notice 4.4.3 is available as a package. apt-get install proj === 1.2 GD === Mapserver requires 1.2 or higher, at this time the Debian package is 1.7.3-0.1 apt-get install libgd1g libgd1g lists !FreeType2 as a dependancy, !FreeType support is required by !MapServer: http://www.mapserver.org/installation/unix.html === 1.3 PHP === I like DSOs for regular PHP work on the server, so let's compile a DSO for PHP and a CGI version that will only be used with PHPMapscript pages (.phtml) {{{ apt-get install flex # PHP needs lex to compile apt-get install apache # else PHP and apache conflict on apache-common version apt-get install apache-dev # PHP needs APXS to compile apt-get install php4 apt-get source php4 # Probably needed for PHPMapscript to compile against }}} We need to compile PHP since the Debian pacakge has --with-regex=PHP while the 3.6 configure.in says that --with-system-regex should be used. (and we want a CGI as well anyway) === 1.3.1 libPDF === I am currently compiling in libPDF into PHP, native Mapserver PDF may be a far neater solution, but this has been convenient and I can use PDF in other apps. PDFlib is not available as a package so we must compile it: {{{ cd /usr/src/pdflib-4.0.2 ./configure make make test make install }}} === 1.3.2 PostgreSQL === apt-get install libpgsql2 === 1.3.2 Compiling and installing PHP === For PHP 4.1.2 source retrived by apt-source, I used: {{{ apt-get install libtiff3g # Required by PHP PDF functions ./configure --with-mysql --with-apxs --with-regex=system --with-postgresql --with-pdflib=/usr/local --with-jpeg --with-tiff --with-zlib make }}} Since we are not making major changes, let's just replace the PHP DSO rather than running make install: {{{ cd /usr/lib/apache/1.3 mv libphp4.so libphp4.so.debian412 cp /usr/src/php4-4.1.2/.libs/libphp4.so libphp4.so.mapserv ln -s libphp4.so.mapserv libphp.so /etc/init.d/apache restart }}} This creates an Apache DSO which Mapserver will refuse to use, but I want to keep the majority of my PHP running from the DSO. Therefore I will compile PHP a second time as a CGI and only associate PHP/Mapscript? with .phtml. To create a CGI php executable: {{{ ./configure --with-mysql --with-regex=system --with-postgresql --with-gd --with-jpeg --with-png --with-freetype --with-pdflib=/usr/local --with-zlib --enable-force-cgi-redirect make }}} To install, follow the instructions in PHPMapScriptCGI (in my case to associate .phtml with the CGI version of PHP), do read these instructions as there are important security considerations to be made. {{{ cp php /usr/lib/cgi-bin/ vi /etc/apache/srm.conf << AddHandler? phtml-script .phtml << Action phtml-script /cgi-bin/php vi /etc/apache/httpd.conf # uncommment mod_actions.so /etc/init.d/apache restart }}} === 1.4 GDAL and OGR === GDAL wants g++, g++ wants libraries from the testing distribution so on advice from a Debian expert, I will leave apt pointed at testing. {{{ cd /usr/src/gdal-1.1.7 apt-get install g++ ./configure make make install # installs to usr/local/ ./bin, ./include, ./share and ./lib vi /etc/ld.so.conf # add /usr/local/lib to libs ldconfig # updates changes to ld.so.conf }}} !MapServer 3.7 seems to require GDAL 1.1.8 for to get "CSLFetchBoolean?" === 2.0 Compile !MapServer === Remember to remove ./config.cache if you change anything! I re-installed GD three times before I noticed this. {{{ apt-get install libwww0 # Needed by --with-wmsclient apt-get install libwww-dev # Also needed by --with-wmsclient apt-get install libjpeg62 # So GD can render jpgs apt-get install libpng2 # So GD can render PNGs apt-get install libgd-dev # replaces libgd1g and more apt-get install proj # upgrade PROJ4 to 4.4.5 ./configure --with-gd --without-tiff --with-freetype --with-proj --with-ogr --with-gdal --with-wmsclient --with-php=/usr/src/php4-4.1.2/ make }}} These notes were written for v 3.6.0, but I have recompiled using 3.6.3 and 3.7 with only minor differences (the replacement of libwww with libcurl and the addition of PDFlib and Ming). === 3.0 Install !MapServer === {{{ cp ./.libs/php_mapscript.so /usr/lib/php/20010901/ # This next bit is an ugly hack until I set up PHP to look at # my extensions directory: ln -s /usr/libs/php/20010901 /usr/local/lib/php4/extensions/no-debug-non-zts-20010901 cp mapserv /usr/lib/cgi-bin # Only needed for our older CGI based apps }}} === 4.0 Testing === ==== Install MapServer 4.2.2 and PHPMapScript from Debian Binary Packages ==== Add the next line in /etc/apt/sources.list for testing: deb http://agrogeomatic.educagri.fr/debian sarge main for stable: deb http://agrogeomatic.educagri.fr/debian woody main And execute: {{{ apt-get update ; apt-get install php-mapscript cgi-mapserver php4 }}} More info in http://agrogeomatic.educagri.fr/debian