The Mapserver 6.0 release comes with a really useful feature, which they snuck in really quietly but deserves more praise in my opinion: a built-in openlayers viewer.
It’s very simple, and only for testing purposes, but it’s so much easier for debugging your mapserver map file compared to the old “mode=map&layers=all” approach.
The syntax for calling it is very similar to the old “mode=map” approach (split into separate lines for clarity here but in reality all one line):
http://localhost/cgi-bin/mapserv? mode=browse& template=openlayers& layers=all& map=/var/www/workshop/itasca.map
So you still need the parameter “map=…” but you include “template=openlayers” and change to “mode=browse”.
In that case though, you can add an additional parameter to your mapserver map file, pointed at a different location for the openlayers library (split into separate lines for clarity again):
To make it look really neat, and get the icons for zooming and panning, you can also download the “theme/default/style.css” stylesheet, and the img folder, both from a standard openlayers install or from here and place those two folders (theme and img) inside your chosen openlayers library location too.
I really think there should have been more of a fanfare about this feature. Testing mapserver layers and map files in a browser is one thing that beginners find very difficult, and it’s not exactly easy. This helps immensely.