FreeBSD 6.2 - MapServer 4.10.1


With postgres/postgis/php_mapscript. this is assuming installation after a clean install of FreeBSD 6.2, with ports, but no x window system.

The other version numbers are :
SERVER_SOFTWARE : Apache/2.2.4 (FreeBSD) mod_ssl/2.2.4 OpenSSL/0.9.7e-p1 DAV/2 PHP/5.2.1 with Suhosin-Patch

It will really help if you have a copy of the FreeBSD Handbook on the screen of another computer, so you can look for FreeBSD help, and obviously access to the MapServer Website.

:w :q is how to write and quit vi, don't forget to press 'esc' before these commands

Libraries

Use ports to install libararies
  1. First, fix your ports-supfile (look in the Handbook) and choose to get all, or nearly all (see the list of directories below). For the once off cost of getting them all, it can save you a lot of frustration (which I have experienced) because a build fails when the version numbers are wrong.
  2. cvsup ports-supfile
    (to make sure you are getting the most recent ones)
  3. Then :
    setenv LDFLAGS -lstdc++
    (this is important for PostgreSQL, and has to be done before compiling, so do it now. You can check it is set by just typing
    setenv
    , and making sure it is there.)
  4. then required libraries using the ports system :
    cd /usr/ports/graphics/jpeg
    make install clean
    Do this for each of :
    jpeg
    png
    tiff
    gd
    proj
    geos
    then for :
    ftp/
    curl
    
    textproc/
    libxml2
    
    print/
    freetype
    pdflib
    
    devel/
    doxygen
    
    lang/
    perl
    php5-extensions
    
    www/
    apache22
    
    
    databases/
    postgresql82-server
    postgis

MapServer installation

  1. Once all the libraries are done, it is time to compile MapServer. From where-ever you have downloaded the mapserver package to:
    tar -xzf mapserver-4.10.1.tar.gz /usr/local/mapserver-4.10.1
    cd /usr/local/mapserver-4.10.1
  2. Next, create a file with the compile commands - much easier than typing in the whole string at the command prompt
    vi config

    and put this in, pretty much as it appears below

    ./configure     --with-freetype=/usr/local/bin \
                    --with-png=/usr/local/lib \
                    --with-jpeg=/usr/local \
                    --with-libiconv=/usr/local \
                    --with-geos=/usr/local/bin/geos-config \
                    --with-ogr=/usr/local/bin/gdal-config \
                    --with-gdal=/usr/local/bin/gdal-config \
                    --with-httpd=/usr/local/sbin/httpd \
                    --with-wfsclient \
                    --with-wmsclient \
                    --enable-runpath \
                    --enable-debug \
                    --with-curl-config=/usr/local/bin/curl-config \
                    --with-proj=/usr/local \
                    --with-pdf=/usr/local \
                    --with-tiff=/usr/local \
                    --with-threads \
                    --with-wcs \
                    --with-postgis=/usr/local/bin/pg_config \
                    --with-php=/usr/local \
                    --with-xml2-config=/usr/bin/xml2-config  # new in 4.10
    :w :q
  3. (assuming you are doing all this as root...)
    chmod 744 config
    ./config
  4. when it has finished (special thanks to Eric 'Lontong' for this fix) you need to edit Makefile in mapscript/php3 path.
    vi mapscript/php3/Makefile
    1. change variable CFLAGS in the top to something else (e.g. CFLAGS1)
    2. then change :

      CFLAGS112 = $(CFLAGS) $(MS_DEFINE) $(MS_INC) $(PHP_INC) $(PHP_REGEX_INC)

      to :

      CFLAGS112 = $(MS_DEFINE) $(MS_INC) $(PHP_INC) $(PHP_REGEX_INC) 
    3. and add :
      CFLAGS = $(CFLAGS1) $(CFLAGS112)
    4. finally, scroll down to in

      compiler %.o: %.c php_mapscript_util.h php_mapscript.h

      $(CC) $(CFLAGS112) -c -o $@ $<

      change :

      $(CFLAGS112)

      to:

       $(CFLAGS)
      :w  :q
  5. then (in /usr/local/mapserver) :
    make
    (Note that this is not make install clean!)

Install & Test

  1. when (if?!) it finishes without errors (it will take some time)
    cp mapserv /usr/local/www/apache22/cgi-bin/
  2. and you can test it by typing
    mapserv -v
    in the directory you have just moved it to.
  3. You also need to move the php extension, and (if you want) add it to your php extensions file list. alternatively, you can call it from your php scripts.
    cp mapscript/php3/php_mapscript.so  /usr/local/lib/php/20060613/
    vi /usr/local/etc/php/extensions.ini 
  4. add the line (use A) :
    extension=php_mapscript.so
    :w :q
  5. Restart Apache
    apachectl graceful
  6. I find it convenient to have a symlink to the data directory, so :
    ln -s /usr/local/www/apache22/data/ htdocs
  7. put your server.php file in the data (htdocs) directory
    vi /htdocs/server.php
    
    
    
    :w :q
  8. then point your web browser at your server :
    10.0.1.3/server.php

    Which tells you that the webserver and php are both working.

  9. and (very exciting)
    10.0.1.3/cgi-bin/mapserv

    which should return you the lovely line : No query information to decode. QUERY_STRING is set, but empty.

Congratulations, you're ready to make maps!