|Version 3 (modified by 13 years ago) ( diff ),|
Environment Variables used by MapServer
A number of environment variables can be used to control MapServer's behavior or specify the location of some resources. We try to list all of them here with either short documentation or a pointer to the relevant documentation.
Note that some of these variables can also be set via a CONFIG directive in a mapfile, but not all of them.
Default mapfile to use if the map=... URL parameter is not provided
It is possible to use an environment variable name as the value of the map=... parameter in a mapserv CGI URL. The value of this environment variable will be used as the mapfile path.
MS_MAPFILE_PATTERN can be used to override the default regular expression which is used to validate mapfile filename extensions.
The default value for this variable is
(Added in 5.4.0, RFC-56)
The optional MS_MAP_PATTERN environment variable can be used to specify a Regular Expression that must be matched by all mapfile paths passed to the mapserv CGI in the map=... URL parameter.
If MS_MAP_PATTERN is not set then any .map file can be loaded.
Example, use Apache's SetEnv directive to restrict mapfiles to the /opt/mapserver/ directory and subdirectories:
SetEnv MS_MAP_PATTERN "^/opt/mapserver/"
(Added in 5.4.0, RFC-56)
The optional MS_MAP_NO_PATH environment variable can be set to any value to forbid the use of explicit paths in the map=... URL parameter. Setting MS_MAP_NO_PATH to any value forces the use of the map=<env_variable_name> mechanism in mapserv CGI URLs.
If this variable is not set then nothing changes and the mapserv CGI still accepts explicit file paths via the map=... URL parameter.
Example, set set MS_MAP_NOPATH and some mapfile paths in Apache's httpd.conf:
SetEnv MS_MAP_NO_PATH "foo" SetEnv MY_MAPFILE "/opt/mapserver/map1/mymapfile.map"
... and then calls the mapserv CGI must use environment variables for the map=... parameter:
Default value for the mode=... CGI parameter. Setting mode=... in the URL takes precedence over the environment variable.
The variable MS_ERRORFILE specifies the location of the logging/debug output, with possible values being either a file path on disk, or one of the following special values:
- “stderr” to send output to standard error. Under Apache stderr is the Apache error_log file. Under IIS stderr goes to stdout so its use is discouraged. With IIS it is recommended to direct output to a file on disk instead.
- “stdout” to send output to standard output, combined with the rest of MapServer’s output
- “windowsdebug” to send output to the Windows OutputDebugString API, allowing the use of external programs like SysInternals debugview to display the debug output.
It is possible to specify MS_ERRORFILE either as an environment variable or via a CONFIG directive inside a mapfile:
CONFIG "MS_ERRORFILE" "/tmp/mapserver.log"
CONFIG "MS_ERRORFILE" "stderr"
If both the MS_ERRORFILE environment variable is set and a CONFIG MS_ERRORFILE is also set, then the CONFIG directive takes precedence.
If MS_ERRORFILE is not set then error/debug logging is disabled. During parsing of a mapfile, error/debug logging may become available only after the MS_ERRORFILE directive has been parsed.
(Added in 5.0.0, see RFC-28)
A default DEBUG level value can be set using the (optional) MS_DEBUGLEVEL environment variable in combination with the MS_ERRORFILE variable.
When set, this value is used as the default debug level value for all map and layer objects as they are loaded by the mapfile parser. This option also sets the debug level for any msDebug() call located outside of the context of a map or layer object, for instance for debug statements relating to initialization before a map is loaded. If a DEBUG value is also specified in the mapfile in some map or layer objects then the local value (in the mapfile) takes precedence over the value of the environment variable.
This option is mostly useful when tuning applications by enabling timing/debug output before the map is loaded, to capture the full process initialization and map loading time, for instance.
(Added in 4.10). See http://www.mapserver.org/utilities/msencrypt.html
The PROJ_LIB environment variable or CONFIG directive can be used to specify the directory where the PROJ.4 data files (including the "epsg" file) are located, if they are not in the default directory where PROJ.4 expects them.
(Added in 5.4.1) Used to specify the location of the Certificate Authority (CA) bundle file to be used by Curl when using HTTPS connections in WMS/WFS client layers. Curl comes bundled with its own CA bundle by default, so this variable is not required unless you have an unusual installation.