Export to GitHub

mapnik-utils - WmsInstallGuide.wiki


Mapnik OGC WMS Server

This is a sample mapnik WMS server configuration, along with a testing Openlayers map.

All files can be found in http://mapnik-utils.googlecode.com/svn/example_code/wms/

Installation

Step 1

Step 2

Here is an example setup with cgi/fastcgi:

(Update WSGI can be the easiest to setup, see http://trac.mapnik.org/wiki/OgcServer)

Configure Apache to allow python cgi execution in a specific directory, like the cgi-bin by either renaming the script to mapnikserv.cgi or adding an Apache directive to a custom directory like: AddHandler cgi-script .cgi .py # add .py

Or Configure fastcgi within apache by adding a directive to your apache conf like: ScriptAlias /mapnik/ /path/to/wms/ <Directory "/path/to/wms/"> AllowOverride All Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all SetHandler fastcgi-script </Directory>

Then make sure that apache can read from that folder: sudo chown -R www-data /path/to/wms/ sudo chgrp -R www-data /path/to/wms/ sudo chmod -R g+rws /path/to/wms/

Then place the mapnikwms.py python script within your cgi-bin or '/path/to/wms/' and make executable: $ chmod +x mapnikwms.py

Step 3

Place the ogcserver.conf and world_map_factory.py beside each other in your location of choice. Fix the hardcoded paths: * The paths inside mapnikwms.py must point to the ogcserver.conf location. * The paths inside map_factory must point to the correct location of the datasource.

Step 4

Go to your browser and open: * http://localhost/cgi-bin/mapnikwms.py?LAYERS=world&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-180.0000000000001,-90,119.46385052802589,209.463850528026&WIDTH=256&HEIGHT=256 * Or use the url prefix 'http://localhost/mapnik/mapnikwms.py?' if you went with the fastcgi approach.

You should see a small tile of the world. If not check your apache logs.

Step 5

Open the openlayers.html (you will likely need to edit the base path in the html) to test your wms served into OpenLayers