MapServer 8.0的全局配置文件说明

MapServer 8.0的全局配置文件说明


发布日期: 2023-07-12 更新日期: 2023-07-12 编辑:bukun 浏览次数: 787

标签:

摘要: 最近将发布 http://webgis.pub 的网站升级到 Debian 12, 其自带的 MapServer 版本为 8.0,2023年04月18日发布的版本为 mapserver-8.0.1 ,能用上这么新的版本真不错。 gislite@whk2:~$ ...

最近将发布 http://webgis.pub 的网站升级到 Debian 12, 其自带的 MapServer 版本为 8.0,2023年04月18日发布的版本为 mapserver-8.0.1 ,能用上这么新的版本真不错。

gislite@whk2:~$ apt search mapserver-bin
Sorting... Done
Full Text Search... Done
mapserver-bin/stable,now 8.0.0-3+b8 amd64 [installed]
  MapServer utilities

运行原来的发布程序,过程没有问题,但是访问 MapServer 服务时发现所有的请求都有问题,除了一些个别的问题,绝大部分信息为:

msLoadConfig(): Unable to access file. See mapserver.org/config_file.html for more information.

上面这个 mapserver.org/config_file.html 根本打不开。根据问题搜索了半天,可能是因为用的人还比较少,找到的信息不多,最后找到官方文档,如下:

CONFIG
As of MapServer 8.0, MapServer has a required global configuration file, implemented through RFC 135, which aims to make configuring MapServer both more secure and straight forward. The configuration file path can be set using the environment variable MAPSERVER_CONFIG_FILE. A default location can also be set at compile time, for different distributions.
Tip For example, compiling from source on Ubuntu, by default MapServer will install a sample config file at /usr/local/etc/mapserver-sample.conf, and you must rename that file to mapserver.conf.
Tip For MS4W users (version >= 5), the config file can be found at /ms4w/ms4w.conf
If MapServer cannot find the config file, an error is returned such as:
    msLoadConfig(): Unable to access file.

意思是说在MapServer 8.0开始,因为安全性的问题需要一个全局配置文件。这个文件可以通过环境变量 MAPSERVER_CONFIG_FILE 指定;如果通过源代码编译,在 Ubuntu 中会生成一个样例配置文件 /usr/local/etc/mapserver-sample.conf

但是对于在 Debian 软件库中如何配置没说,找 Debian 相关信息也没找到。后来按Debian的一些惯例试了一下,记录解决方法如下。

在Debian 12中,查找类似文件。

gislite@whk2:/owg$ locate mapserver | grep conf
/usr/share/doc/cgi-mapserver/examples/mapserver-sample.conf
/usr/share/mapserver/ogcapi/templates/html-plain/conformance.html

这样找到样例文件,将其复制到 /etc 文件夹下:

sudo cp /usr/share/doc/cgi-mapserver/examples/mapserver-sample.conf  /etc/mapserver.conf

这样再请求 MapServer 服务,会出现下面错误:

msCGILoadMap(): Web application error. CGI variable "map" fails to validate.

对这个配置文件进行修改,注意 ^/owg ,使用正则表达式声明 Mapfile 所在的路径。如果不限定具体的目录, 可以使用 ^/

CONFIG
  ENV
    MS_MAP_PATTERN "^/owg" ## required when referencing mapfiles by path

如此这样,MapServer 8.0 可以与往常版本一样运行了。

另外在 MapServer 8.0 中原来使用的 Mapfile 也碰到一些小问题需要修改。在 https://github.com/gislite/webgis-pub 可以查看源代码,已经修改确保在 MapServer 8.0中的运行。

相关推荐

关注公众号
获取免费资源

随机推荐


Copyright © Since 2014. 开源地理空间基金会中文分会 吉ICP备05002032号

Powered by TorCMS

OSGeo 中国中心 邮件列表

问题讨论 : 要订阅或者退订列表,请点击 订阅

发言 : 请写信给: osgeo-china@lists.osgeo.org