-
Notifications
You must be signed in to change notification settings - Fork 2
LightSpeedMapServer
This is a configuration of Map Server WMS as fast-cgi module of Lighttpd. Here I am compiling all main software packages from the source code on a 64bit Linux operatingBR
system to get maximum performance. I hope my readers having experience in installing & configuring software packages under Linux platform. I prefer a CentOS 5.4 ×86_64 Linux BR
minimal server installation, because it is quite stable for me so far.
BR
''Prerequisites''
BR
Make sure that you have installed the following packages, normally it comes with the operating system installation.
cc gcc-c++ python python-devel krb5-devel readline-devel make swig pcre-devel libpng libpng-devel
bzip2-devel fontconfig fontconfig-devel libxml2-devel penssl-devel
curl-devel giflib-devel zlib-devel gettext libjpeg-devel libtiff-devel
If any of the package is not installed, install it by using YUM. For example if gcc is missing
yum install gcc-c++
Ok, let’s start with the main software packages installation for Map Server,BR
'''PostgresSQL''[[BR]]
The world’s most advanced open source database server.I prefer PostgresSQL server to store the vector map data, for fast searching and rendering of WMS map tiles.
BRDownload the source[http://www.postgresql.org/]BR
Installation & Configuration.BR
tar -xzf postgresql-8.4.2.tar.gz
cd postgresql-8.4.2/
./configure —prefix=/usr/local/pgsql —with-perl —with-python —with-krb5
make
make install
adduser postgres
mkdir /var/lib/pgsql
chown -R postgres /var/lib/pgsql
su postgres
/usr/local/pgsql/bin/initdb -D /var/lib/pgsql/data
/usr/local/pgsql/bin/postgres -i -h localhost -p 5432 -D /var/lib/pgsql/data &
Now your PostgreSQL server is up and running. If you need an init.d startup script, download it from here [http://nishad.us/docs/softwares/postgresql.txt]BR
'''FastCGI''[[BR]]
FastCGI is a protocol for interfacing interactive programs with a web server. This is a variation on the earlier Common Gateway Interface (CGI). Unlike CGI, It cannot BR
duplicates the universality of CGI overnight. It runs applications in processes isolated from the core Web server, which provides greater security than APIs. Not only does
FastCGI restore the strengths of CGI, it also adds two new benefits like Distributed computing and Multiple extensible roles.BR
Download the source[http://www.fastcgi.com/]
Installation & Configuration
tar -xzf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0/
./configure —prefix=/usr/local/
make
make install
You have installed the FastCGI executables and libraries now, we will use this later while configuring the Map Server.BR
'''Proj.4'''
It is Cartographic Projections library is designed as a standard Unix filter utility to be employed with other pro-grams in the generation of maps and charts and, in many BRcases, used in map digitizing applications for conversion of State Plane Coordinate Systems to and from geographic coordinates.BR
Download the source[http://trac.osgeo.org/proj/]
Installation & Configuration
tar -xzf proj-4.7.0.tar.gz
cd proj-4.7.0/
./configure —prefix=/usr/local/
make
make install
You have successfully compiled the Proj4 libraries required for Map Server.
'''LighHTTPD'''
Lighttpd is a web server designed and optimized for high performance environments, with a small memory footprint compared to other web-servers and effective management of theBR cpu-load. This is a perfect solution for every server which is suffering load problems.
Download the source[http://www.lighttpd.net/]
Installation & Configuration
tar -xzf lighttpd-1.4.26.tar.gz
cd lighttpd-1.4.26/
./configure —prefix /usr/local/ —bindir=/usr/local/bin/ —sbindir=/usr/local/sbin/ —libexecdir=/usr/local/libexec/
—libdir=/usr/local/lib/ —includedir=/usr/local/include —sysconfdir=/usr/local/lighthttpd —datarootdir=/var/www/
—datadir=/var/www —with-memcache
make
make install
install -Dp ./doc/lighttpd.conf /etc/lighttpd/lighttpd.conf
sed -e ‘s/FOO/lighttpd/g’ doc/rc.lighttpd.redhat > /etc/init.d/lighttpd
chmod a+rx /etc/init.d/lighttpd
/etc/init.d/lighttpd start
You have successfully compiled and configured your fast & secure Lighttpd web server.
'''Free Type'''
Free Type is a software font engine that is designed to be small, efficient, highly customizable, and portable while capable of producing high-quality output. It can be used BRin graphics libraries, display servers, font conversion tools, text image generation tools, and many other products as well.
Download the source[http://www.freetype.org/]
Installation & Configuration
tar -xzf freetype-2.3.12.tar.gz
cd freetype-2.3.12/
./configure —prefix=/usr/local/
make
make install
You have successfully compiled the Free Type libraries required for Map Server.
'''GEOS'''
Geos GEOS is a Geometry Engine which aims to contain the complete functionality of Java Topology Suite. This includes all the GIS Simple Features for SQL spatial predicate BRfunctions and spatial operators, as well as specific JTS enhanced topology functions.
Download the source [http://trac.osgeo.org/geos/]
Installation & Configuration
tar -xjf geos-3.2.0.tar.bz2
cd geos-3.2.0/
./configure —prefix=/usr/local/ —enable-python —enable-swig
make
make install
You have successfully compiled the Geos libraries required for Map Server.
'''GD'''
GD is used for dynamic creation of images like PNG, JPEG and GIF images, among other formats. GD is commonly used to generate charts, graphics, thumbnails, and most anythingBR else, on the fly.
Download the source [http://www.libgd.org/]
Installation & Configuration
tar -xzf gd-2.0.35.tar.gz
cd gd-2.0.35/
./configure —prefix=/usr/local/ —with-png=/usr/ —with-jpeg=/usr/local/ —with-fontconfig=/usr/
make
make install
You have successfully compiled the GD binaries and it’s libraries required for Map Server.
'''PHP'''
PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. Here we are configuring PHP with BR
Postgre Sql and GD with is required for PHP mapscript, and compiling as fast-cgi to get the maximum security and speed.
Download the source [http://php.net/]
Installation & Configuration
tar -xzf php-5.3.2.tar.gz
cd php-5.3.2/
./configure —prefix=/usr/local/php5 —with-fastcgi=/usr/local —with-regex=php —enable-debug —enable-magic-quotes
—enable-libgcc —with-libxml-dir=/usr/local/ —with-openssl=/usr —with-kerberos=/usr/local/ —with-zlib=/usr
—with-bz2=/usr/local/ —with-curl=/usr/local/ —with-gettext=/usr/local/ —enable-mbstring —with-pgsql=/usr/local/pgsql/
—enable-soap —enable-zip —with-gd=/usr/local/ —with-jpeg-dir=/usr/local/ —with-png-dir=/usr/local/ —with-mhash=/usr/local/
make
make install
cp -pr php.ini-production /usr/local/php5/lib/php.ini
You have successfully compiled PHP as fast-cgi in the server.
'''PostGIS'''
PostGIS PostGIS adds support for geographic objects to the PostgreSQL object-relational database. In effect, PostGIS “spatially enables” the PostgreSQL server, allowing it toBR be used as a backend spatial database for geographic information systems (GIS).
Download the source[ http://postgis.refractions.net/]
Installation & Configuration
tar -xzf softwares/postgis-1.5.1.tar.gz
cd postgis-1.5.1/
./configure —prefix=/usr/local/ —with-geosconfig=/usr/local/bin/geos-config —with-pgsql=/usr/local/pgsql/bin/pg_config
make
make install
You have successfully configured postGIS with PostgreSQL and Geos, compiled the source and installed the binaries. Now you create a PostgreSQL database and spatially enables BRit by importing the PostGIS sql functions.
createdb -U postgres testgis
createlang -U postgres plpgsql testgis
psql -U postgres testgis < postgis/postgis.sql
psql -U postgres testgis < spatial_ref_sys.sql
'''GDAL'''
GDAL (Geospatial Data Abstraction Library) is a library for reading and writing raster geospatial data formats. As a library, it presents a single abstract data model to theBR calling application for all supported formats. It may also be built with a variety of useful command-line utilities for data translation and processing.
Download the source http://www.gdal.org/
Installation & Configuration
tar -xzf gdal-1.7.1.tar.gz
cd gdal-1.7.1/
./configure —prefix=/usr/local/ —with-png=/usr/ —with-libtiff=/usr/local/ —with-jpeg=/usr/local/
—with-gif=/usr/ —with-pg=/usr/local/pgsql/bin/pg_config —with-geos=/usr/local/ —with-python
make
make install
You have successfully compiled Gdal with png,tiff,jpeg,gif,PostgreSQL and python. Now your Gdal library is available to build the Map Server.
'''Map Server'''
MapServer is geographic data rendering engine, providing spatial context where needed. It allows you to create geographic image maps that can direct users to content. It wasBR originally developed by the University of Minnesota (UMN) ForNet project in cooperation with NASA. The main features are,
* Advanced cartographic output
* Scale dependent feature drawing and application execution
* Feature labeling including label collision mediation
* Fully customizable, template driven output
* True Type fonts
* Map element automation (scalebar, reference map, and legend)
* Thematic mapping using logical- or regular expression-based classes
* Support for popular scripting and development environments, ie PHP, Python, Perl, Ruby, Java.
* Cross-platform support
* Support of numerous Open Geospatial Consortium (OGC) standards, ie WMS,WFS, WMC, WCS, Filter Encoding, SLD, GML, SOS, OM
* A multitude of raster and vector data formats, ie TIFF/GeoTIFF, EPPL7, ESRI shapfiles, PostGIS, ESRI ArcSDE, Oracle Spatial, MySQL
* On-the-fly map projection with 1000s of projections through the Proj.4 library.
Download the source [http://mapserver.org/]
Installation & Configuration
tar -xzf mapserver-5.6.1.tar.gz
cd mapserver-5.6.1/
./configure —prefix=/usr/local/ —with-gdal=/usr/local/bin/gdal-config —with-ogr=/usr/local/bin/gdal-config
—with-httpd=/usr/local/sbin/lighttpd —with-curl=/usr/bin/curl-config[[BR]] —enable-debug
—with-proj=/usr/local/ —with-tiff=/usr/ —with-gd=/usr/local/ —with-jpeg=/usr/local/ —with-freetype=/usr/local/
—with-threads —with-postgis=/usr/local/pgsql/bin/pg_config —with-xml2-config=/usr/bin/xml2-config
—with-png=/usr/ —with-wmsclient —with-wmsserver —with-fastcgi=/usr/local/ —with-wfs with-wfsclient
—with-gif=/usr/ —with-geos=/usr/local/bin/geos-config —with-php=/usr/local/php5
make
make install
cp -pr mapserv /var/www/cgi-bin/
You have successfully compiled the Map Server with all it’s prerequisites and bindings,and as fast-cgi binary. Now you can test your installation by running “mapserv” binary.BR If you get below output, it seems your installation is successful.
./mapserv -v
MapServer version 5.6.1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=AGG
SUPPORTS=FREETYPE SUPPORTS=ICONV SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=FASTCGI
SUPPORTS=THREADS SUPPORTS=GEOS INPUT=TIFF INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
PHP & Map server FastCGI configuration with Lighttpd. Edit Lighttpd.conf,
vi /etc/lighttpd/lighttpd.conf
and insert below configuration under the fastcgi section.
fastcgi.server = ( “.php” =>
( “localhost” =>
(
“socket” => “/tmp/php-fastcgi.socket”,
“bin-path” => “/usr/local/php5/bin/php-cgi”
)
),
“/map” =>
( “localhost” =>
(
“socket” => “/tmp/mapserver-fastcgi.socket”,
“bin-path” => “/var/www/cgi-bin/mapserv”,
“max-procs” => 1,
“check-local” => “disable”
)
)
)
Restart your Lighttpd server.
/etc/init.d/lighttpd restart
Your Light Speed FastCGI Map Server Web Map Service(WMS) is up and running now. :) Try it from the URL http://localhost/maps?map=yourmapfile.map
Contact me for any further help.
Nishad AliyarBR
[email protected]BR
http://nishad.us/docs