Installation and Configuration MapServer
It's irritating to set up the initial runtime environment when you start a job, especially when you follow the steps step by step, but the basic "Hello World" is still not going to happen, or even maddening. Building an operating environment requires comprehensive technology, and some experience requires a bit of luck. Don't underestimate the ability to configure the operating environment, many programmers are unable to build their own development environment, let alone the real production environment.
Basic Requirements for Installing and Configuring MapServer
MapServer is open source software written in C, which relies on some open source or free libraries itself, such as Shapelib, FreeType, Proj.4, GDAL/OGR, GD Library, Regex. MapServer is written in C, and the subprojects it depends on have a corresponding C language implementation. When you run MapServer, you must install the relevant class libraries, and sometimes rely on specific versions of some class libraries. When compiling and installing MapServer, you need to have some understanding of these libraries.
MapServer itself is a program that generates maps, but provides a CGI interface (MapServer CGI runs on PHP), which can be called via Web access. So many times in order to run MapServer, you need to install a Web server (such as Apache 2), as well as tools (such as FastCGI) that let the application (MapServer) communicate with the Web server (Apache). Apache 2 does not have CGI turned on by default.
- GD Library: MapServer uses GDD graphics library to represent images in GIF, PNG and JPEG formats. These images are viewed on the browser via MapServer CGI.
- Regex: Regex is a regular expression library.
- JPEG library: JPEG image is generated by GD call.
- PNG library: Generates a PNG image by calling GD.
- Zlib: Used by libpng to provide graphics compression.
- FreeType 2: Called by GD. Provides TrueType support.
- PROJ.4: Proj.4 is used for dynamic projection transformation. WMS, WFS or WCS Services also need its support.
- GDAL/OGR: MapServer uses the GDAL/OGR library to read data in raster (GDAL) and vector (OGR) format.
- ArcSDE: ArcSDE is ESRI's spatial database engine (it is not free) to support MapServer into the SDE database.
- EPPL7: Used to read the EPPL7 database and older versions of Erdas LAN/GIS files. It is a built-in library as a MapServer.
Debian / Ubuntu system installation
Debian / Ubuntu is my most popular Linux distribution, and its well-designed package management is really enjoyable. To install MapServer, you only need to run the following installation command (requires administrator privileges):
In Debian 9:
Apt install -y apache2 php7.0 libapache2-mod-fcgid cgi-mapserver mapserver-bin libapache2-mod-php A2enmod authnz_fcgi A2enmod cgi Service apache2 restart
In Ubuntu 18.04:
Apt install -y apache2 php7.2 libapache2-mod-fcgid cgi-mapserver mapserver-bin libapache2-mod-php A2enmod authnz_fcgi A2enmod cgi Service apache2 restart
There is almost no difference, except that the newer
php 7.2 version is used in Ubuntu 18.04. When installing these packages, they will be installed automatically if the corresponding dependencies are missing.
A little explanation about FastCGI.
CGI (Common Gateway Interface) defines the method of interaction between the WEB server and the external content generator, usually referred to as CGI programs or CGI scripts, which is the simplest and most common way to implement dynamic pages on a website. It is possible to interact between an external program and a web server. But early CGI programs run in separate processes and created a process for each web request. This method is very easy to implement, but it is inefficient and difficult to extend. Faced with a large number of requests, the massive creation and demise of the process has greatly reduced the performance of the operating system. In addition, because the address space cannot be shared, resource reuse is also limited.
FastCGI uses a continuous (daemon) process to process a series of requests that are managed by the FastCGI server, not the web server. When a request comes in, the web server passes the environment variable and the page request through a socket such as the FastCGI process and the web server (both local) or a TCP connection ( The FastCGI process is passed to the FastCGI process at the remote server farm.
Installation under Windows system
Installing MapServer under Windows also requires installing Apache2, CGI, and MapServer programs. These also have binary packages under Windows, but this step-by-step installation is cumbersome and prone to problems.
It is recommended to use
MS4W (MapServer 4 Windows), the link is: https://www.ms4w.com/.