Installing MapServer on a LAMP server (linux)

Table of Contents

Installing MapServer on a LAMP server Installation This installation guide will give you simple step-by-step instructions of installing a MapServer, with PHP/MapScript and OneGeology level 1 compliant, WMS onto a computer with a LINUX OS with an Apache http web server already running. This guide includes instructions on the installation of the compulsory libraries to run MapServer 5.6.5 and OneGeology level 1 WMS, all libraries required to serve the BGS exemplar services, and other libraries required to serve Arabic, and Hebrew fonts. The net result of this installation is something similar to that achievable with the MS4W installation. You may opt to install less or more libraries to give less or more functionality, depending on your requirements. More detailed information about a linux MapServer installation is available from the MapServer site (http://mapserver.org/installation/unix.html) Though we haven’t yet updated this section for the latest version of MapServer (6.0.0) the process will be very similar. Users of Ubuntu/Debian systems may now find that they are able to get the latest version of MapServer by adding the following Personal Package Archives to their system’s software sources: ppa:ubuntugis/ppa Official stable UbuntuGIS packages ppa:ubuntugis/ubuntugis-unstable Unstable releases of Ubuntu GIS packages Before starting the installation process, it would be convenient if you log in as root in your Linux machine. Throughout this guide, we would be using the Linux console to run and install the software and the needed libraries. In this document, we assume that the Root Linux prompt is #. Each command would be executed after pressing <ENTER>. MapServer ~ download the latest source code from the OSGEO MapServer repository (http://download.osgeo.org/mapserver/). You must install all supporting libraries (as below) before compiling MapServer. Required external libraries (you must have these libraries to install MapServer). We shall try to update the cookbook to show the current releases of these libraries, please let us know if we are showing older versions. Please note the versions we show in the examples are the ones we used to build our Linux MapServer solution and may not be the latest version. zlib (http://www.zlib.net) zlib should be on your system by default. 1.2.5 is the current release with security patches. If this doesn’t exist on your system, you must install it before libpng. libpng (http://www.libpng.org/pub/png/libpng.html) libpng should be on your system by default. 1.2.44 is the current release with security patches, although versions all the way back to 1.2.7 should work. freetype (http://www.freetype.org/index2.html) Version 2.x or above is required by GD. Current release is 2.4.2. GD (http://libgd.org/Main_Page) libgd is used by MapServer for rendering images. Version 2.0.28 or greater required. Version 2.0.29 or later is required to use curved (following) labels, and version 2.0.34 is required for antialiasing (1 pixel wide lines/outlines). Current release is 2.0.36. Other libraries we will use in this installation libproj (http://trac.osgeo.org/proj/) libproj provides projection support for MapServer. Version 4.4.6 or greater is required. Current version is version 4.7.0 libcurl (http://curl.haxx.se/libcurl libcurl is the foundation of OGC (WFS/WMS/WCS) client and server support. Version 7.10 or greater is required. Current version is 7.21.1. GDAL (http://www.gdal.org/) GDAL is a translator library for raster geospatial data formats and provides access to at least 42 different raster formats. Current version is 1.7. OGR (http://www.gdal.org/ogr/) OGR is a library (and command-line tools) providing read (and sometimes write) access to at least 18 different vector file formats including ESRI Shapefiles, PostGIS, and Oracle Spatial. OGR is a part of the GDAL library. libjpeg (http://www.ijg.org/) libjpeg allows MapServer to render images in JPEG format. A sufficient version should be installed by default on your system. Version 8b is the current stable version. GEOS (http://trac.osgeo.org/geos/) GEOS allows MapServer to do spatial predicate and algebra operations (within, touches, etc & union, difference, intersection). Requires MapServer version 4.10 or greater, current version is 3.2.2. libxml2 (http://xmlsoft.org/) libxml2 is required to use OGC SOS support in MapServer (versions 4.10 and greater). Current version is 2.7.7. libxslt (http://xmlsoft.org/XSLT/) required for PostGIS. Current version is 1.1.26. libpq (http://www.postgresql.org/docs/8.4/interactive/libpq.html) libpq is required to support the use of PostGIS geometries within the PostgreSQL database. Ideally, your client library matches the database you are querying from. FriBidi (http://www.fribidi.org/) FriBidi is an implementation of the Unicode Bidirectional Algorithm, and is used to provide support for languages with characters that flow from right to left. Current release is 0.10.9. We will download all the required libraries into the /usr/local/src directory using the ‘wget’ program. It is recommended that you browse to the home page for each library to ensure you obtain the format that is best suited to your system, to check there are no known issues that might affect your install, and to ensure you have the most up-to-date library for your system. #cd /usr/local/src #wget http://download.osgeo.org/mapserver/mapserver-5.6.5.tar.gz #wget http://www.gzip.org/zlib/zlib-1.2.3.tar.gz #wget http://prdownloads.sourceforge.net/libpng/libpng-1.2.40.tar.gz?download #wget http://sourceforge.net/projects/freetype/files/freetype2/2.3.11/freetype-2.3.11.tar.gz/download Etc... After successfully downloading the compressed files using the ‘wget’ program, we will need to uncompress using the ‘tar’ program. The following steps would uncompress the downloaded files: #tar -xzvf mapserver-5.6.5.tar.gz #tar -xzvf zlib-1.2.3.tar.gz #tar -xzvf libpng-1.2.40.tar.gz #tar -xzvf freetype-2.3.11.tar.gz #tar -xzvf gd-2.0.36.tar.gz #tar -xzvf proj-4.7.0.tar.gz Etc... Uncompressing the .tar.gz files will create a sub-directory, with a name corresponding to the root name of the compressed file, within the /usr/local/src/ directory, containing the files needed to build the library on your system. Before continuing with building the supporting libraries and MapServer, it is worth ensuring all other system libraries and components are up-to-date. In Ubuntu (as per this install) you do this by: #apt-get update #apt-get upgrade #apt-get install build-essential Now we need to change to each sub-directory in turn to compile and install the libraries on our system using the following sequence of commands: #./configure #make #make install Note you may review any configuration options by using the help option (in this example we direct the output to the ‘less’ program) as: #./configure --help | less Use q to quit from less. E.g. #cd zlib-1.2.3 #./configure #make #make install #cd .. By default the libraries created will be installed in the /usr/local/lib directory. Check there are no errors cited after running both the ‘configure’ and ‘make’ programs. If there are errors you will need to fix these first before continuing. For example you might get a warning that you are missing a dependant library, or an existing library is too old, or the make program found more than one copy of a library. You might be able to fix the issues by specifying non-default configure options (see the configure help), or editing the PATH environment variable. You should clean up any files before re-running configure and make. This might be possible using the ‘make clean’ command, but if the errors happen when you are trying to compile MapServer (for example) you may need to delete the sub-folder and start again. Example of recompiling, if you get a compilation error: #cd /usr/local/src/zlib-1.2.3 #./configure #make But you get errors here so then (when you have fixed the issues) you could try: #make clean #./configure #make If you get the same (or similar) error then: #cd /usr/local/src/ #rm -r zlib-1.2.3 #tar -xzvf zlib-1.2.3.tar.gz #cd zlib-1.2.3 #./configure #make #make install Once you have installed all the dependent libraries you can now install MapServer. We will install onto a Ubuntu server (9.10) with Apache, PHP, Perl, Python, and PostgreSQL with PostGIS already installed and running. We will force some configuration options, other options are picked up by default (for example AGG support). #cd /usr/local/src/mapserver-5.6.5 #./configure --with-ogr --with-gdal --with-wfsclient --with-wmsclient --with-proj --with-wcs --with-postgis --with-geos --with-sos --with-experimental-png --with-fribidi-config --with-threads --enable-debug #make Note for MapServer you don’t need to run ‘make install’, you just need to move (or copy) the mapserv file to an appropriate cgi-bin executable directory accessible by your Apache web server. This location will vary depending on your version of Linux; in Ubuntu 9.10 the default location for cgi-bin files is /usr/lib/cgi-bin #cp mapserv /usr/lib/cgi-bin/mapserv The mapserv binary created needs to have —rwxr-xr-x permissions to be able to execute You can check permissions using: #ls —l mapserv If needed you can change permissions using: #chmod 755 mapserv To test you have compiled mapserv with all appropriate options you can check the version: #./mapserv —v You should get an output like: MapServer version 5.6.5 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=PDF OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=THREADS SUPPORTS=GEOS SUPPORTS=RGBA_PNG INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE To test you have mapserv accessible through your web server you can use the ‘lynx’ text browser package (available through apt-get): #apt-get install lynx #lynx http://127.0.0.1/cgi-bin/mapserv Or you could simply use the wget program (which will retrieve the output as a text file): #cd /tmp #wget http://127.0.0.1/cgi-bin/mapserv #less mapserv You should get the message "No query information to decode. QUERY_STRING is set but empty" Congratulations! You have now got MapServer installed and configured to run in your web server. Section last modified: 24 June 2011.]]>

Leave a Reply

Your email address will not be published. Required fields are marked *