Setting up MapServer/MapScript version 3.6 on RedHat 7.2

NOTE: these instructions have been used on RedHat 7.3 clean install and were found to work with one slight problem noted below in the mapserver section. (Actually, it's not, so visit Detailed instructions to compile/install PHP MapScript 3.6 on RedHat 7.3.)


Configure a brand new RedHat 7.2 server to host MapServer-based apps:

  • MapServer 3.6 (WMS)
  • PHPMapScript 3.6
  • GMap

Server Information

We start with a clean RedHat 7.2 install, configured with Apache preinstalled but no PHP.

Source packages will be compiled under "/home/src" and installed in /usr/local

Web Server installed under /var/www:

 DocRoot = /var/www/html
 CGI dir = /var/www/cgi-bin
 Config  = /etc/httpd/conf

MapServer apps will be installed under /home/msapps using a logical link from /var/www/html/ -> /home/msapps/

List of required files or packages

proj-4.4.5.tar.gz proj-nad27-1.1.tar.gz


libwww-5.3.2-20011211.tar.gz (CVS version as of 2001-12-11)



... and just for testing:



  $ cd /home/src
  $ tar xzvf ~/arch/proj-4.4.5.tar.gz 
  $ cd proj-4.4.5/nad
  $ tar xzvf ~/arch/proj-nad27-1.1.tar.gz 
  $ cd ..
  $ ./configure
  $ make
  $ sudo make install
  $ cd ..

... also copy the custom "epsg" file (with EPSG:42xxx projections:

  $ sudo cp ~/arch/epsg /usr/local/share/proj/epsg

... edit /etc/ and add /usr/local/lib, then run

  $ sudo /sbin/ldconfig


  $ tar xzvf ~/arch/gdal-1.1.7.tar.gz 
  $ cd gdal-1.1.7
  $ ./configure 
  $ make
  $ sudo make install
  $ cd ..
  $ sudo /sbin/ldconfig


... w3c-libwww version 5.3.2 with the latest fixes can be obtained only via CVS, but for this install, I've tared the copy that was previously downloaded and built on another server... it's simpler this way ;) (

  $ tar xzvf ~/arch/libwww-5.3.2-20011211.tar.gz  
  $ cd libwww
  $ ./configure
  $ make
  $ sudo make install
  $ cd ..
  $ sudo /sbin/ldconfig


RH7.2 comes with a copy of gd-1.8.4 (without GIF) preinstalled. Since we want gd-1.8.4 with GIF (, we have to uninstall gd-devel-1.8.4-4.rpm and then install our new copy of gd under /usr/local/lib. This won't affect or break existing applications because removing the RPM only removes /usr/lib/ (logical link) and /usr/lib/libgd.a and the associated headers, but the physical file ( will remain there for applications that came preinstalled on the RH system.

  $ sudo rpm -e gd-devel-1.8.4-4 

  $ tar xzvf ~/arch/gd-1.8.4gif.tar.gz  
  $ cd gd-1.8.4

... edit Makefile to compile with Freetype1... MapServer seems to have problem loading fonts when using gd compiled with Freetype2 on RH7.x

  LIBS=-lgd -lpng -lz -ljpeg -lm -lttf 
  INCLUDEDIRS=-I. -I/usr/include/freetype1/freetype -I/usr/include/X11 -I/usr/X11R6/include/X11 -I/usr/local/include

  $ make
  $ sudo make install
  $ cd ..


Note: We want PHP to use our custom GD compiled with Freetype 1.3, but PHP won't detect freetype by default. PHP looks for freetype1 headers under /usr/include/freetype and $with_ttf/include/freetype, but RH7.2 has them under /usr/include/freetype1/freetype ... this has been filed as bug 17130 in the PHP bugs database. Until this is fixed, for PHP to detect the freetype1 headers, we have to create a logical link in /usr/include:

  $ cd /usr/include
  $ sudo ln -s freetype1/freetype freetype

... then we can proceed with normal PHP configuration.

  $ tar xzvf ~/arch/php-4.2.3.tar.gz  
  $ cd php-4.2.3

  $ ./configure  --enable-shared --with-regex=system --with-gd=/usr/local      --with-ttf=/usr --enable-gd-native-ttf --with-jpeg-dir=/usr      --with-png-dir=/usr --with-zlib --enable-force-cgi-redirect      --enable-dbase --with-config-file-path=/etc/httpd/conf

  $ make
  $ strip php
  $ sudo make install
  $ sudo cp php /var/www/cgi-bin/php
  $ sudo cp php.ini-dist /etc/httpd/conf/php.ini
  $ cd ..

... edit /etc/httpd/conf/php.ini to set:

  log_errors = On
  extension_dir = /usr/local/lib/php/extensions/

... edit /etc/httpd/conf/httpd.conf

    # And for PHP 4.x, use:
 ## Commented-out... we bypass the PHP module and use PHP4 as
 ## a CGI instead ... see below
 ## ... old config ...
 #    <IfModule? mod_php4.c>
 #        AddType application/x-httpd-php .php .php4 .php3 .phtml
 #        AddType application/x-httpd-php-source .phps
 #    </IfModule?>
 ## New PHP 4 CGI config
 ## Use a different application type to bypass the PHP DSO
 AddType application/x-httpd-php4 .php4 .php3 .phtml .php
 Action  application/x-httpd-php4 /cgi-bin/php

Then restart the server using

  $ sudo /etc/rc.d/init.d/httpd restart


  $ tar xzvf ~/arch/mapserver-3.6.3.tar.gz
  $ cd mapserver-3.6.3
  $ ./configure --with-proj --with-wmsclient --with-libwww --with-gdal --enable-runpath --with-php=../php-4.2.3 --without-tiff --with-gd --enable-force-freetype1

  $ make

  $ cp mapserv /var/www/cgi-bin/mapserv_36
  $ sudo cp mapscript/php3/ /usr/local/lib/php/extensions/

Setup MapServer IMAGEDIR and cleanup script

  $ sudo mkdir /tmp/ms_tmp
  $ sudo chmod 777 /tmp/ms_tmp

... also add the commands above to /etc/rc.d/rc.local as well to recreate the directory when the system reboots, after a /tmp cleanup...

... create a logical link for the ms_tmp directory on the web server

  $ cd /var/www/html
  $ ln -s /tmp/ms_tmp ms_tmp

... create "/etc/cron.daily/" ... you can also place the file in /etc/cron.hourly/ for busier sites...

 #! /bin/sh
 # MapServer temporary file cleanup - run daily by cron
 # Flush all files from /tmp/ms_tmp older than 6 hours (360 minutes)
 find /tmp/ms_tmp -name "*.*" -amin +360 -exec rm -f {} \;
 exit 0


Install a copy of the latest GMap demo to test our installation:

 $ cd /home/msapps
 $ tar xzvf ~/arch/gmap-ms36.tar.gz 

... create a link from the htdocs directory to the application's htdoc:

 $ cd /var/www/html/
 $ ln -s /home/msapps/gmap/htdocs gmap

You should now be able to run GMap at

Last modified 15 years ago Last modified on Jan 27, 2009, 8:50:42 AM
Note: See TracWiki for help on using the wiki.