Key Object Hierarchy

MAP
  LAYER
   CLASS  L
      LABEL C,D
      STYLE C
   GRID L
   JOIN L
  LEGEND
  PROJECTION M,L
  QUERYMAP
  REFERENCE
  SCALEBAR
  WEB M
    METADATA W,L
  OUTPUTFORMAT M

MAP Properties

CONFIG key value
ERROR_FILE
EXTENT
FONTSET
IMAGETYPE
IMAGESIZE
SHAPEPATH
 relative or absolute 
 path data folder
SIZE width height

WEB Properties

EMPTY
ERROR
MAXSCALEDENOM
METADATA
MINSCALEDENOM

LAYER Specific Properties

CLASS*
CLASSGROUP string
CONNECTION
CONNECTIONTYPE 
 common: ogr | postgis 
 | wms | plugin
 Note numerous to choose from
 but not compiled 
 in by default. 
 ESRI shapefile (local) 
 is assumed if left blank
DATA  file or table
LABELITEM fieldname
FILTER where condition
OPACITY integer|alpha 
 (0-100) 100 opaque
PLUGIN path to plugin driver 
 e.g. "C:\ms\msplugin_mssql2008.dll"
STATUS
TYPE 
 point|line|polygon|circle|
  annotation|raster|
  query|chart
PROCESSING driver specific
UMN Mapserver MapFile 5.2 Cheat Sheet PDF Version Official MapFile Documentation URL: http://mapserver.osgeo.org/mapfile
+ Is a sub-object of more than one kind of Object too numerous to mention.
B - applies to LABEL objects
C - applies to CLASS objects
D - applies to LEGEND objects
L - applies to LAYER objects
M - applies to MAP objects
W - applies to WEB objects
* - complex attribute - an object in and of itself Indentation shows highest level it can appear

* Multiple instances of these can exist in an object.
Field names in mapserver are case sensitive for example PostGIS generally use lower case and ESRI shape/Oracle uppercase
Mapserver supports variable substitution pretty much anywhere in a file using %variable% syntax. The %variable% is then passed via querystring or post.

Anatomy of a Map File

MAP 
# Start of map file
  # DEBUG value can be between [0-5] for Mapserver 5.
  DEBUG 5 
  #ERROR_FILE denotes file to redirect errors
  ## e.g C:/mapserv/logs/error_file.log
  ERROR_FILE "/mapserv/logs/error_file.log"  
# Define the outputformats your map will support. 
 
  # OUTPUT FORMATS GO HERE

  ###: Overall map attributes go in this section
  ## : http://mapserver.osgeo.org/mapfile/mapObj
  # Location of your Proj directory needed for projection
  # for windows "C:/mapserv/scripts/proj/" 
  CONFIG PROJ_LIB "/mapserv/scripts/proj/"  
  NAME "BOILER"  #name to give your map service
  # This is the extent of your map in the 
  # default projection of your map
  #EPSG:4326 for Boston
  EXTENT -71.1914 42.2277 -70.9867 42.3968 
  # Default size of your map in pixels.  
  # This can be overriden by passing 
  # in parameters via WMS or CGI Template
  SIZE 500 500
  # Location of ESRI shape, MapInfo files, tiles etc. 
  # NOTE: you can explicitly specify full paths 
  # in layers DATA element
  # or relative to this path
  SHAPEPATH "/mapservdata/" 
  UNITS "dd"
  SYMBOLSET "symbols/symbols.sym"
  FONTSET "symbols/fonts/font.lst"
  # This is the default output type - can be overridden 
  # in WMS or Mapserve Request
  IMAGETYPE "jpeg"
  # This is the set of allowable templates to be 
  # used by map passed in via url
  # This is not relevant for WMS GetMap Requests
  # If no template is passed in via CGI url, 
  # then the Template defined in layer or WEB section is used
  TEMPLATEPATTERN "printable.html|loader.html|blankloader.htm"  
  # Default projection of your map - all layers in different 
  # projection will be reprojected to this
  PROJECTION 
   "init=epsg:4326"
  END   
  WEB
    TEMPLATE loader.html
    MINSCALEDENOM 100
    MAXSCALEDENOM 100000
    # Where to log requests most be writable by webserver
    LOG "D:/mapserv/tmp/mymapfile.log"
    # The physical location of where to put temp images
    # Again this folder needs to be writable by the webserver
    IMAGEPATH "D:/mapserv/tmp/"    
    # This is the web virtual path of the physical IMAGEPATH
    IMAGEURL "/mapserv/tmp/"
    METADATA
      #WFS/WMS/OWS meta data goes here
    END
  END #End Web
  
  # LAYER DEFINITIONS GO HERE
END # Map File
Boston GIS     Paragon Corporation     Postgres OnLine Journal PostGIS in Action

CLASS Specific Attributes

GROUP string
EXPRESSION boolean expression
 e.g. ([fieldname] > 5) 

LABEL Specific Attributes

ANGLE  degrees|auto|
 follow|field
COLOR r g b | field
PARTIALS true|false
POSITION ul|uc|ur|cl
 |cc|cr|ll|lc|lr|auto
PRIORITY integer|field

Common Attributes

BACKGROUNDCOLOR B,C,L
COLOR r g b B,C,L
DEBUG [off|on|0|1|2|3|4|5]L,M
IMAGECOLOR B,D
NAME C,L,M,W
OUTLINECOLOR B,C,L
OVERLAYBACKGROUNDCOLOR 
OVERLAYCOLOR 
OVERLAYOUTLINECOLOR
OVERLAYSIZE
OVERLAYMINSIZE
OVERLAYMAXSIZE
OVERLAYSYMBOL
SHADOWCOLOR B
SIZE
STYLE*
SYMBOL
TEMPLATE D,L,M

METADATA Attributes

WFS_TITLE L,W
WFS_SRS M
WMS_TITLE L,W
WMS_ABSTRACT L,W
WMS_ACCESSCONSTRAINTS
WMS_ONLINERESOURCE M
WMS_SRS L,W
OWS_TITLE L,W
OWS_* L,W