| 1 | |
| 2 | == Light Speed Map Server == |
| 3 | |
| 4 | |
| 5 | 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 operating[[BR]] |
| 6 | 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]] |
| 7 | minimal server installation, because it is quite stable for me so far. |
| 8 | [[BR]] |
| 9 | ''Prerequisites'' |
| 10 | [[BR]] |
| 11 | Make sure that you have installed the following packages, normally it comes with the operating system installation. |
| 12 | {{{ |
| 13 | cc gcc-c++ python python-devel krb5-devel readline-devel make swig pcre-devel libpng libpng-devel |
| 14 | bzip2-devel fontconfig fontconfig-devel libxml2-devel penssl-devel |
| 15 | curl-devel giflib-devel zlib-devel gettext libjpeg-devel libtiff-devel |
| 16 | }}} |
| 17 | If any of the package is not installed, install it by using YUM. For example if gcc is missing |
| 18 | {{{ |
| 19 | yum install gcc-c++ |
| 20 | }}} |
| 21 | Ok, let’s start with the main software packages installation for Map Server,[[BR]] |
| 22 | '''PostgresSQL'''[[BR]] |
| 23 | 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. |
| 24 | [[BR]]Download the source[http://www.postgresql.org/][[BR]] |
| 25 | Installation & Configuration.[[BR]] |
| 26 | {{{ |
| 27 | tar -xzf postgresql-8.4.2.tar.gz |
| 28 | cd postgresql-8.4.2/ |
| 29 | ./configure —prefix=/usr/local/pgsql —with-perl —with-python —with-krb5 |
| 30 | make |
| 31 | make install |
| 32 | adduser postgres |
| 33 | mkdir /var/lib/pgsql |
| 34 | chown -R postgres /var/lib/pgsql |
| 35 | su postgres |
| 36 | /usr/local/pgsql/bin/initdb -D /var/lib/pgsql/data |
| 37 | /usr/local/pgsql/bin/postgres -i -h localhost -p 5432 -D /var/lib/pgsql/data & |
| 38 | }}} |
| 39 | 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]] |
| 40 | '''FastCGI'''[[BR]] |
| 41 | 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]] |
| 42 | 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 |
| 43 | FastCGI restore the strengths of CGI, it also adds two new benefits like Distributed computing and Multiple extensible roles.[[BR]] |
| 44 | Download the source[http://www.fastcgi.com/] |
| 45 | Installation & Configuration |
| 46 | {{{ |
| 47 | tar -xzf fcgi-2.4.0.tar.gz |
| 48 | cd fcgi-2.4.0/ |
| 49 | ./configure —prefix=/usr/local/ |
| 50 | make |
| 51 | make install |
| 52 | }}} |
| 53 | You have installed the FastCGI executables and libraries now, we will use this later while configuring the Map Server. |
| 54 | '''Proj.4''' |
| 55 | 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 [[BR]]cases, used in map digitizing applications for conversion of State Plane Coordinate Systems to and from geographic coordinates. |
| 56 | Download the source[http://trac.osgeo.org/proj/] |
| 57 | Installation & Configuration |
| 58 | {{{ |
| 59 | tar -xzf proj-4.7.0.tar.gz |
| 60 | cd proj-4.7.0/ |
| 61 | ./configure —prefix=/usr/local/ |
| 62 | make |
| 63 | make install |
| 64 | }}} |
| 65 | You have successfully compiled the Proj4 libraries required for Map Server. |
| 66 | '''LighHTTPD''' |
| 67 | 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 the[[BR]] cpu-load. This is a perfect solution for every server which is suffering load problems. |
| 68 | Download the source[http://www.lighttpd.net/] |
| 69 | Installation & Configuration |
| 70 | {{{ |
| 71 | tar -xzf lighttpd-1.4.26.tar.gz |
| 72 | cd lighttpd-1.4.26/ |
| 73 | p<>. ./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 |
| 74 | make |
| 75 | make install |
| 76 | install -Dp ./doc/lighttpd.conf /etc/lighttpd/lighttpd.conf |
| 77 | sed -e ‘s/FOO/lighttpd/g’ doc/rc.lighttpd.redhat > /etc/init.d/lighttpd |
| 78 | chmod a+rx /etc/init.d/lighttpd |
| 79 | /etc/init.d/lighttpd start |
| 80 | }}} |
| 81 | You have successfully compiled and configured your fast & secure Lighttpd web server. |
| 82 | '''FreeType''' |
| 83 | FreeType 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 [[BR]]in graphics libraries, display servers, font conversion tools, text image generation tools, and many other products as well. |
| 84 | Download the source[http://www.freetype.org/] |
| 85 | Installation & Configuration |
| 86 | {{{ |
| 87 | tar -xzf freetype-2.3.12.tar.gz |
| 88 | cd freetype-2.3.12/ |
| 89 | ./configure —prefix=/usr/local/ |
| 90 | make |
| 91 | make install |
| 92 | }}} |
| 93 | You have successfully compiled the FreeType libraries required for Map Server. |
| 94 | '''GEOS''' |
| 95 | 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 [[BR]]functions and spatial operators, as well as specific JTS enhanced topology functions. |
| 96 | Download the source [http://trac.osgeo.org/geos/] |
| 97 | Installation & Configuration |
| 98 | {{{ |
| 99 | tar -xjf geos-3.2.0.tar.bz2 |
| 100 | cd geos-3.2.0/ |
| 101 | ./configure —prefix=/usr/local/ —enable-python —enable-swig |
| 102 | make |
| 103 | make install |
| 104 | }}} |
| 105 | You have successfully compiled the Geos libraries required for Map Server. |
| 106 | '''GD''' |
| 107 | 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 anything[[BR]] else, on the fly. |
| 108 | Download the source [http://www.libgd.org/] |
| 109 | Installation & Configuration |
| 110 | {{{ |
| 111 | tar -xzf gd-2.0.35.tar.gz |
| 112 | cd gd-2.0.35/ |
| 113 | ./configure —prefix=/usr/local/ —with-png=/usr/ —with-jpeg=/usr/local/ —with-fontconfig=/usr/ |
| 114 | make |
| 115 | make install |
| 116 | }}} |
| 117 | You have successfully compiled the GD binaries and it’s libraries required for Map Server. |
| 118 | '''PHP''' |
| 119 | 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]] |
| 120 | PostgreSql and GD with is required for PHP mapscript, and compiling as fast-cgi to get the maximum security and speed. |
| 121 | Download the source [http://php.net/] |
| 122 | Installation & Configuration |
| 123 | {{{ |
| 124 | tar -xzf php-5.3.2.tar.gz |
| 125 | cd php-5.3.2/ |
| 126 | ./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[[BR]] —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/ |
| 127 | make |
| 128 | make install |
| 129 | cp -pr php.ini-production /usr/local/php5/lib/php.ini |
| 130 | }}} |
| 131 | You have successfully compiled PHP as fast-cgi in the server. |
| 132 | '''PostGIS''' |
| 133 | PostGIS PostGIS adds support for geographic objects to the PostgreSQL object-relational database. In effect, PostGIS “spatially enables” the PostgreSQL server, allowing it to[[BR]] be used as a backend spatial database for geographic information systems (GIS). |
| 134 | Download the source[ http://postgis.refractions.net/] |
| 135 | Installation & Configuration |
| 136 | {{{ |
| 137 | tar -xzf softwares/postgis-1.5.1.tar.gz |
| 138 | cd postgis-1.5.1/ |
| 139 | ./configure —prefix=/usr/local/ —with-geosconfig=/usr/local/bin/geos-config —with-pgsql=/usr/local/pgsql/bin/pg_config |
| 140 | make |
| 141 | make install |
| 142 | }}} |
| 143 | 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 [[BR]]it by importing the PostGIS sql functions. |
| 144 | {{{ |
| 145 | createdb -U postgres testgis |
| 146 | createlang -U postgres plpgsql testgis |
| 147 | psql -U postgres testgis < postgis/postgis.sql |
| 148 | psql -U postgres testgis < spatial_ref_sys.sql |
| 149 | }}} |
| 150 | '''GDAL''' |
| 151 | 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 the[[BR]] calling application for all supported formats. It may also be built with a variety of useful command-line utilities for data translation and processing. |
| 152 | Download the source http://www.gdal.org/ |
| 153 | Installation & Configuration |
| 154 | {{{ |
| 155 | tar -xzf gdal-1.7.1.tar.gz |
| 156 | cd gdal-1.7.1/ |
| 157 | ./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 |
| 158 | make |
| 159 | make install |
| 160 | }}} |
| 161 | You have successfully compiled Gdal with png,tiff,jpeg,gif,PostgreSQL and python. Now your Gdal library is available to build the Map Server. |
| 162 | Map Server |
| 163 | '''Map Server''' |
| 164 | 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 was[[BR]] originally developed by the University of Minnesota (UMN) ForNet project in cooperation with NASA. The main features are, |
| 165 | * Advanced cartographic output |
| 166 | * Scale dependent feature drawing and application execution |
| 167 | * Feature labeling including label collision mediation |
| 168 | * Fully customizable, template driven output |
| 169 | * TrueType fonts |
| 170 | * Map element automation (scalebar, reference map, and legend) |
| 171 | * Thematic mapping using logical- or regular expression-based classes |
| 172 | * Support for popular scripting and development environments, ie PHP, Python, Perl, Ruby, Java. |
| 173 | * Cross-platform support |
| 174 | * Support of numerous Open Geospatial Consortium (OGC) standards, ie WMS,WFS, WMC, WCS, Filter Encoding, SLD, GML, SOS, OM |
| 175 | * A multitude of raster and vector data formats, ie TIFF/GeoTIFF, EPPL7, ESRI shapfiles, PostGIS, ESRI ArcSDE, Oracle Spatial, MySQL |
| 176 | * On-the-fly map projection with 1000s of projections through the Proj.4 library. |
| 177 | Download the source [http://mapserver.org/] |
| 178 | Installation & Configuration |
| 179 | {{{ |
| 180 | tar -xzf mapserver-5.6.1.tar.gz |
| 181 | cd mapserver-5.6.1/ |
| 182 | ./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 [[BR]]—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 [[BR]]with-wfsclient —with-gif=/usr/ —with-geos=/usr/local/bin/geos-config —with-php=/usr/local/php5 |
| 183 | make |
| 184 | make install |
| 185 | cp -pr mapserv /var/www/cgi-bin/ |
| 186 | }}} |
| 187 | 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. |
| 188 | {{{ |
| 189 | ./mapserv -v |
| 190 | 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 [[BR]]SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=TIFF INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE |
| 191 | }}} |
| 192 | PHP & Map server FastCGI configuration with Lighttpd. Edit Lighttpd.conf, |
| 193 | {{{ |
| 194 | vi /etc/lighttpd/lighttpd.conf |
| 195 | }}} |
| 196 | and insert below configuration under the fastcgi section. |
| 197 | {{{ |
| 198 | fastcgi.server = ( “.php” => |
| 199 | ( “localhost” => |
| 200 | ( |
| 201 | “socket” => “/tmp/php-fastcgi.socket”, |
| 202 | “bin-path” => “/usr/local/php5/bin/php-cgi” |
| 203 | ) |
| 204 | ), |
| 205 | “/map” => |
| 206 | ( “localhost” => |
| 207 | ( |
| 208 | “socket” => “/tmp/mapserver-fastcgi.socket”, |
| 209 | “bin-path” => “/var/www/cgi-bin/mapserv”, |
| 210 | “max-procs” => 1, |
| 211 | “check-local” => “disable” |
| 212 | ) |
| 213 | ) |
| 214 | ) |
| 215 | }}} |
| 216 | Restart your Lighttpd server. |
| 217 | {{{ |
| 218 | /etc/init.d/lighttpd restart |
| 219 | }}} |
| 220 | 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 |
| 221 | Contact me for any further help. |
| 222 | |
| 223 | Nishad Aliyar |
| 224 | nishad.n.a@gmail.com |