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:
- Mapserver: is the main software.
- GD: used by MapServer for rendering images, version 2.0.28 or greater is required.
- PROJ.4: provides projection support for MapServer (also needed by PostGIS), version 4.4.6 or greater is required.
- GEOS: enables MapServer to do spatial operation (within, touches, union, difference, intersection), also needed by PostGIS.
- GDAL: provides access to at least 42 different raster formats.
- OGR: provides access to at least 18 different vector formats.
- CURL: is the foundation of OGC (WFS, WMS, WCS) client and server support, requires version 7.10 or greater.
- PostGIS: adds support for geographic objects to the PostgreSQL.
Source: http://download.osgeo.org/mapserver/mapserver-5.0.2.tar.gz
Source: http://www.libgd.org/releases/gd-2.0.35.tar.gz
Source: ftp://ftp.remotesensing.org/proj/proj-4.6.0.tar.gz
Source: http://geos.refractions.net/downloads/geos-3.0.0.tar.bz2
Source: http://download.osgeo.org/gdal/gdal-1.5.1.tar.gz
Source: http://download.osgeo.org/gdal/gdal-1.5.1.tar.gz
Source: http://curl.haxx.se/download/curl-7.18.1.tar.gz
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 \
- [lorenz@devel>>php-5.2.3]$ make
- [lorenz@devel>>php-5.2.3]$ cp sapi/cgi/php-cgi /data/www/cgi-bin
> –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
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 \
- [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
> –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/
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:
- Edit file /usr/local/apache/conf/httpd.conf and add two lines below:
- Restart apache (#/usr/local/apache/bin/apachectl restart)
extension_dir = “/usr/local/lib/php/extensions” extension = “php_mapscript.so”
AddType application/x-httpd-php-cgi .phtml Action application/x-httpd-php-cgi /cgi-bin/php-cgi
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:
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 .







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
hola kaztel, ¿podría mostrar varias líneas de sus mensajes de error?
Gracias
Hola Lorenz
Ya solucione mi problema me faltaban unas dependencias del gdal.
Muchas Gracias
Thnx alot,
I’ve been having problems installing on openSUSE10.3
Would this work on OpenSUSE??
thanks again.
@styxGH
I never tested it on openSuse, but if all required libraries are installed, it must be going well
Best Regards
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
Lorenz boleh………
dudeng 99’ers
one more link giving steps for mapserver installation
http://sudhendra.blogspot.com/
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!
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
there is no file shptreest in mapserver but shptreetst
mas, boleh minta tutorial pemasangan apache dan postgreSQL nya mas?
thanks before 😀