• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • About
  • Projects
    • GStaticMap WP Plugin
  • Contact
  • Privacy Policy

Lorenz Blog

All About Web & Mobile Application Development

  • Featured Articles
  • Gadgets
    • Android
    • Blackberry
  • Programming
    • Android
    • PHP
    • Java Script
    • MySQL
    • Postgresql
    • Flex
    • Web
  • Software
    • Mac OS
    • Windows
    • Linux
  • Web
You are Here » Home >> Information Technology >> Software >> Linux >> Installing MapServer and PHP MapScript on Linux

Installing MapServer and PHP MapScript on Linux

May 4, 2008 by Lorensius Londa 13 Comments

Introduction

MapServer is an open source and free software for rendering maps, images, and vector data on the web. MapServer was originally developed by the University of Minnesota (UMN) ForNet project in cooperation with NASA and the Minnesota Department of Natural Resources. Presently, the MapServer project is hosted by the TerraSIP, a NASA sponsored project between the UMN and consortium of land management interests (http://mapserver.gis.umn.edu).

MapServer can be compiled on many platforms and operating systems, but in this tutorial, I will focus on unix like system, especially Linux.

Prerequisites

Operating system used in this tutorial is Linux Fedora Core 7 with Apache (httpd-2.0.55), PHP (php-5.2.3), and PostgreSQL(postgresql-8.2.4) already installed using manual source installation (not using default rpm package). Required libraries that already installed are libpng, libjpeg, libtiff, and zlib. Installation manual for those softwares and libraries are beyond the scope of this tutorial.

Required softwares and libraries:

  1. Mapserver: is the main software.
  2. Source: http://download.osgeo.org/mapserver/mapserver-5.0.2.tar.gz

  3. GD: used by MapServer for rendering images, version 2.0.28 or greater is required.
  4. Source: http://www.libgd.org/releases/gd-2.0.35.tar.gz

  5. PROJ.4: provides projection support for MapServer (also needed by PostGIS), version 4.4.6 or greater is required.
  6. Source: ftp://ftp.remotesensing.org/proj/proj-4.6.0.tar.gz

  7. GEOS: enables MapServer to do spatial operation (within, touches, union, difference, intersection), also needed by PostGIS.
  8. Source: http://geos.refractions.net/downloads/geos-3.0.0.tar.bz2

  9. GDAL: provides access to at least 42 different raster formats.
  10. Source: http://download.osgeo.org/gdal/gdal-1.5.1.tar.gz

  11. OGR: provides access to at least 18 different vector formats.
  12. Source: http://download.osgeo.org/gdal/gdal-1.5.1.tar.gz

  13. CURL: is the foundation of OGC (WFS, WMS, WCS) client and server support, requires version 7.10 or greater.
  14. Source: http://curl.haxx.se/download/curl-7.18.1.tar.gz

  15. PostGIS: adds support for geographic objects to the PostgreSQL.
  16. Source: http://www.postgis.org/download/postgis-1.3.3.tar.gz

Note:

Apache was installed under /usr/local/apache

PostgreSQL was installed under /usr/local/pgsql

All previously installed libraries (libpng, libjpeg, libtiff, and zlib) were installed under /usr/lib

Apache root directory is /data/www/html, cgi-bin directory is /data/www/cgi-bin

Installation

GD

Installation steps:

  • [lorenz@devel>>installer]$ tar –xzvf gd-2.0.35.tar.gz
  • [lorenz@devel>>installer]$ cd gd-2.0.35
  • [lorenz@devel>>gd-2.0.35]$ ./configure
  • [lorenz@devel>>gd-2.0.35]$ make
  • [lorenz@devel>>gd-2.0.35]$ make install

Note: default installation directory is /usr/local

PROJ.4

Installation steps:

  • [lorenz@devel>>installer]$ tar –xzvf proj-4.6.0.tar.gz
  • [lorenz@devel>>installer]$ cd proj-4.6.0
  • [lorenz@devel>>proj-4.6.0]$ ./configure
  • [lorenz@devel>>installer]$ make
  • [lorenz@devel>>installer]$ make install

Note: default installation directory is /usr/local

GEOS

Installation steps:

  • [lorenz@devel>>installer]$ tar –xjvf geos-3.0.0.tar.bz2
  • [lorenz@devel>>installer]$ cd geos-3.0.0
  • [lorenz@devel>>geos-3.0.0]$ ./configure
  • [lorenz@devel>>geos-3.0.0]$ make
  • [lorenz@devel>>geos-3.0.0]$ make install

Note: default installation directory is /usr/local

[ad#ad-1]

GDAL

Installation steps:

  • [lorenz@devel>>installer]$ tar –xzvf gdal-1.5.1.tar.gz
  • [lorenz@devel>>installer]$ cd gdal-1.5.1
  • [lorenz@devel>>gdal-1.5.1]$ ./configure
  • [lorenz@devel>>gdal-1.5.1]$ make
  • [lorenz@devel>>gdal-1.5.1]$ make install

Note: default installation directory is /usr/local

CURL

Installation steps:

  • [lorenz@devel>>installer]$ tar –xzvf curl-7.18.1.tar.gz
  • [lorenz@devel>>installer]$ cd curl-7.18.1
  • [lorenz@devel>>curl-7.18.1]$ ./configure
  • [lorenz@devel>>curl-7.18.1]$ make
  • [lorenz@devel>>curl-7.18.1]$ make install

Note: default installation directory is /usr/local

Update ld-config

  • [lorenz@devel>>installer]$ cd /etc/ld.so.conf.d/
  • [lorenz@devel>>ld.so.conf.d]$ echo /usr/local/lib > usrlocalib.conf
  • [lorenz@devel>>ld.so.conf]$ /sbin/ldconfig

PostGIS

Installation steps:

  • [lorenz@devel>>installer]$ tar –xzvf postgis-1.3.3.tar.gz
  • [lorenz@devel>>installer]$ cd postgis-1.3.3
  • [lorenz@devel>>postgis-1.3.3]$ ./configure –with-pgsql=/usr/local/pgsql/bin/pg_config –with-proj –with-geos
  • [lorenz@devel>>postgis-1.3.3]$ make
  • [lorenz@devel>>postgis-1.3.3]$ make install

Recompile PHP as CGI

Installation steps:

  • [lorenz@devel>>installer]$ cd php-5.2.3
  • [lorenz@devel>>php-5.2.3]$ ./configure –enable-force-cgi-redirect \
  • > –with-gd=/usr/local/ \
    > –with-jpeg-dir=/usr/lib \

    > –with-png-dir=/usr/lib \

    > –with-tiff-dir=/usr/lib \

    > –with-zlib-dir=/usr/lib \

    > –with-freetype-dir=/usr/lib \

    > –without-ttf \

    > –with-mysql=/usr/local/mysql/ \

    > –with-pgsql=/usr/local/pgsql/ \

    > –with-curl=/usr/local/ \

    > –with-gettext \

    > –enable-ftp \

    > –enable-xml \

    > –with-zlib \

    > –with-regex=system \

    > –enable-dbase \

    > –enable-dbx \

    > –with-config-file-path=/usr/local/lib

  • [lorenz@devel>>php-5.2.3]$ make
  • [lorenz@devel>>php-5.2.3]$ cp sapi/cgi/php-cgi /data/www/cgi-bin

Note: DO NOT do a “make install”

MapServer

Installation steps:

  • [lorenz@devel>>installer]$ tar –xzvf mapserver-5.0.2.tar.gz
  • [lorenz@devel>>installer]$ cd mapserver-5.0.2
  • [lorenz@devel>>mapserver-5.0.2]$ ./configure –with-ogr=/usr/local/bin/gdal-config \
  • > –with-gdal=/usr/local/bin/gdal-config \
    > –with-httpd=/usr/local/apache/bin/httpd \
    > –with-wfsclient \
    > –with-wmsclient \
    > –enable-debug \
    > –with-curl-config=/usr/local/bin/curl-config
    > –with-proj=/usr/local \
    > –with-tiff \
    > –with-gd=/usr/local \
    > –with-jpeg \
    > –with-freetype=/usr/ \
    > –with-threads \
    > –with-wcs \
    > –with-postgis=/usr/local/pgsql/bin/pg_config \
    > –with-libiconv=/usr \
    > –with-geos=/usr/local/bin/geos-config \
    > –with-xml2-config=/usr/bin/xml2-config \
    > –with-sos \
    > –with-php=../php-5.2.3/

  • [lorenz@devel>>mapserver-5.0.2]$ make
  • [lorenz@devel>>mapserver-5.0.2]$ cp mapserv legend scalebar shp2img shp2pdf shptree shptreest shptreevis sortshp tile4ms /data/www/cgi-bin

Note: DO NOT do a “make install”

PHP MapScript installation steps:

  • [lorenz@devel>>mapserver-5.0.2]$ mkdir /usr/local/lib/php/extensions
  • [lorenz@devel>>mapserver-5.0.2]$ cp mapscript/php3/php_mapscript.so /usr/local/lib/php/extensions
  • [lorenz@devel>>mapserver-5.0.2]$ cd /usr/local/lib
  • Edit file php.ini and add two lines below:
  • extension_dir = “/usr/local/lib/php/extensions” extension = “php_mapscript.so”

  • Edit file /usr/local/apache/conf/httpd.conf and add two lines below:
  • AddType application/x-httpd-php-cgi .phtml Action application/x-httpd-php-cgi /cgi-bin/php-cgi

  • Restart apache (#/usr/local/apache/bin/apachectl restart)

Test PHP Mapscript

To test PHP MapScript that already installed:

  • Go into web root directory (/data/www/html)
  • Create php file and add phpinfo() line into the file
  • Save the file as info.phtml
  • Open browser and point to http://localhost/info.phtml
  • If installation is successful, the phpinfo page should contain part like this:

MapScript

To test drawing map, you can download simple demo application from http://www.londatiga.net/downloads/tutorial/phpmapscript-demo.tar.gz

To test PHP MapScript that already installed:

  • [lorenz@devel>>installer]$ cp phpmapscript-demo.tar.gz /data/www/html
  • [lorenz@devel>>installer]$ cd /data/www/html
  • [lorenz@devel>>installer]$ tar –xzvf phpmapscript-demo.tar.gz
  • [lorenz@devel>>installer]$ chmod 777 tmp
  • Open browser and point to http://localhost/phpmapscript-demo
  • If all things running well it should display a map

You can download PDF version of this tutorial here

UPDATES 06 June 2008

For latest version of Linux such as Fedora Core 9, it comes with newest gcc compiler (gcc 4.3) , compiling those packages above may cause some errors (error when run make command on geos-3.0.0, gdal-1.5.1 and mapserver-5.0.2). To overcome this problem, download the latest version of those packages. At the time i write this update, latest version of gdal is gdal-1.5.2RC3 and mapserver is mapserver-5.0.3, for geos, download the following patch: geos-3.0.0-gcc43.patch .

Facebooktwitterredditpinterestlinkedinmailby feather

Related posts:

  1. Installing TeamSpeak Server on FreeBSD
  2. Installing Windows XP on Acer Travelmate 6291 Laptop (SATA Hard Drive Without Floppy)
  3. How to Setup MQTT Server Using Mosquitto and Libwebsocket on Freebsd
  4. How to Create Android Update Zip Package

Filed Under: Featured Articles, Information Technology, Linux, Software Tagged With: fedora, GIS, install mapscript linux, install mapserver, install mapserver freebsd, install mapserver linux, linux, MapServer, PHP MapScript, PostGIS

About Lorensius Londa

Passionate web and mobile application developer. Co-founder of TRUSTUDIO, loves programming, Android, aviation, travelling, photography, coffee and gym mania.

Reader Interactions

Comments

  1. kaztel says

    May 19, 2008 at 6:48 am

    Una consulta… me aparece un error al instalar gdal, al momento de hacer el “make” sale el siguiente mensaje.
    make[1]:se sale del directorio ‘/usr/local/gdal-1.5.1/apps’

    Alguna sugerencia??
    Gracias

    Reply
  2. lorenz says

    May 19, 2008 at 12:54 pm

    hola kaztel, ¿podría mostrar varias líneas de sus mensajes de error?

    Gracias

    Reply
  3. lorenz says

    May 20, 2008 at 11:07 pm

    Hola Lorenz
    Ya solucione mi problema me faltaban unas dependencias del gdal.
    Muchas Gracias

    Reply
  4. styxGH says

    September 14, 2008 at 1:44 am

    Thnx alot,
    I’ve been having problems installing on openSUSE10.3
    Would this work on OpenSUSE??

    thanks again.

    Reply
  5. lorenz says

    September 17, 2008 at 9:30 am

    @styxGH
    I never tested it on openSuse, but if all required libraries are installed, it must be going well

    Best Regards

    Reply
  6. Carpintonto says

    October 15, 2008 at 9:12 pm

    I had a make error like kaztel.

    /usr/bin/ld: cannot find -lodbcinst
    collect2: ld returned 1 exit status
    make: *** [shp2img] Error 1

    found the fix here:
    https://bugzilla.redhat.com/show_bug.cgi?id=232792#c2
    a redhat bugzilla I think about building the mapserver 4.10.1-2 rpm

    ” This is because `$GDAL_CONFIG –dep-libs` in configure adds
    unnecessary linkages.

    Applying a patch for configure to remove the above seems
    good. For sed usage,
    ”
    ——————————————————-

    %sed -i.libs -e ‘s|`\$GDAL_CONFIG –dep-libs`||’ configure

    Reply
  7. iksandi says

    February 13, 2010 at 1:16 pm

    Lorenz boleh………

    dudeng 99’ers

    Reply
  8. ssk says

    March 20, 2010 at 10:34 am

    one more link giving steps for mapserver installation

    http://sudhendra.blogspot.com/

    Reply
  9. Vibram says

    September 9, 2010 at 1:44 pm

    Yeah, I have to admire the landlord’s unique point of view, this article is very comprehensive and considerable on the analyse, and greatly inspired me. In addition, I would like to share that some other blog’s article, content is also very good, if you scan it,there will be a suprise!

    Reply
  10. Amirul says

    October 24, 2010 at 11:54 am

    cp mapscript/php3/php_mapscript.so /usr/local/lib/php/extensions

    I did not get any php_mapscript.so file at mapscript/php3/

    How will i get this?

    Thanks
    Amirul

    Reply
  11. Amirul says

    October 24, 2010 at 1:48 pm

    there is no file shptreest in mapserver but shptreetst

    Reply
  12. Arunaru says

    May 26, 2012 at 7:32 pm

    mas, boleh minta tutorial pemasangan apache dan postgreSQL nya mas?

    thanks before 😀

    Reply

Leave a Reply Cancel reply

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

Primary Sidebar

About Me

A husband, father of two, passionate software developer, diy lover and home baker who loves to learn new things. Read More…

  • Facebook
  • GitHub
  • Google+
  • Instagram
  • Twitter
  • YouTube

Featured Articles

How to Setup MQTT Server Using Mosquitto and Libwebsocket on Freebsd

Blue Bamboo P25 Printer Android Demo Application With Source Code

Simple JSON RPC Client for Android

How to Send Message to Google Cloud Messaging (GCM) Server Using JSON and PHP

Footer

Recent Comments

  • Aditya Dabas on About
  • Ayten Göksenin Barutçu on How to Make Android Map Scrollable Inside a ScrollView Layout
  • mang jojot on About
  • Hussain on How to Programmatically Scan or Discover Android Bluetooth Devices

Recent Posts

  • How to Fix Blank Screen on WordPress Add/Edit Post Page
  • How to Programmatically Restart the ESP32 Board
  • How to Get Hardware Info of ESP32
  • How to Setup MQTT Server Using Mosquitto and Libwebsocket on Freebsd

Latest Tweets

  • @tricahyono_bowo @infobandung @infobdg Wah kejauhan om 355 days ago
  • Wilujeng enjing sadayana..Mohon info tempat powder coating dan sandblasting yg recommended di Bandung dunk @infobandung @infobdg359 days ago

Copyright © 2023 · Magazine Pro on Genesis Framework · WordPress · Log in