MapServer’s Web Technology Environment

Compared with the complete software suite, the setup of the MapServer operating environment may be more troublesome, but its flexibility is also the reason why many people like it. This section explains the other technologies involved in MapServer operation, and understands some problems encountered during installation and configuration.

MapServer itself is a program that generates maps, but provides a CGI interface, which can be accessed through Web to call related functions. So many times in order to run MapServer, you need to install a web server (such as Apache 2, Nginx, or Microsoft’s IIS), and tools (such as FastCGI) that allow applications (MapServer) to communicate with the web server (Apache). Technically, MapServer is considered a stateless process based on HTTP. Stateless means that it processes a request and then stops running.

The simplest form of MapServer is to run as an executable CGI application on a web server. The MapServer CGI executable acts as a middleman between the map data file and the web server program requesting the map. These requests are passed from the web server to MapServer CGI in the form of CGI parameters; the MapServer CGI program accesses a map file and obtains information from the data source; the MapServer application processes it according to the information, creates the map, and feeds it back to the web server; the final feedback is to The user’s web browser.

The operation of MapServer depends on the web server, and MapServer application developers need to be aware that the development of the web server may affect changes in their applications.

Apache web server

Use the Apache Web server in this book companion web site to provide MapServer with basic Web service capabilities. The success of Apache Web servers lies in its open source code, an open development team, cross-platform applications that can run on almost all Unix, Windows, Linux system platforms, and its portability.

Apache HTTP Server is an open source web server of the Apache Software Foundation that can run on most computer operating systems and is one of the most popular Web server-side software due to its multi-platform and security usage. The birth of Apache was dramatic. When the NCSAWWW server project came to a halt, people who used the NCSAWWW server began exchanging the patches they used for the server, and they quickly realized that it was necessary to set up a forum to manage those patches. In this way, the Apache Group was born, and the group later founded Apache on the basis of the NCSA. It is fast, reliable, and compiles interpreters such as Perl/Python into the server with simple API extensions. Apache is taken from the pronunciation of “a patchy server”, meaning a patched server, because it is free software, so people are constantly coming to develop new features, new features, and modifying the original defects. Apache is characterized by simplicity, fast speed, stable performance, and can be used as a proxy server.

Originally used only for small or experimental Internet networks, Apache has since expanded into a variety of Unix systems, especially with perfect support for Linux. Apache has a variety of products that support SSL technology and multiple virtual hosts. Apache is a process-based structure that consumes more system expenses than threads and is less suitable for multiprocessor environments, so when an Apache Web site is expanded, it is usually time to increase servers or expand cluster nodes rather than add processors.

Over the past few years, Apache’s share of the million-level site has been declining steadily, to 33.04 percent by December 2019. While still the largest share, its profit margins are shrinking rapidly and its dominance could be challenged by Nginx within a year. Despite these losses, the number of Web-facing computers running Apache software does continue to grow. If you’re going to choose a Web server, there’s no doubt that Apache is one of the best options.

Apache web server software has the following features:

  1. Supports major versions of HTTP communication protocols, such as the widely used HTTP/1.1 and the latest HTTP/2;

  2. Have a simple and powerful file-based configuration method;

  3. Supports common gateway interfaces;

  4. Supports IP- and domain-based virtual hosts;

  5. Supports HTTP authentication in a variety of ways;

  6. Integrated proxy server module;

  7. Supports real-time monitoring of server status and customizing server logs;

  8. Support server-side containing instructions (SSI) and secure Socket layers (SSL);

  9. Provides tracking of user session procedures;

  10. Support for FastCGI.

Concept snare of public gateway interface (CGI)

Common Gateway Interface (Common Gateway Interface, CGI) is the specification of external programs when the Web server runs, and programs written in CGI can extend server functionality, other software that follows CGI communication rules called CGI programs or CGI scripts. CGI programs are the simplest and most common way to implement dynamic pages on a Web site, making it possible to interact with external programs and Web servers. During the interaction, the CGI program processes the data obtained from the Web server (such as data processing for forms, querying databases, etc.) and then returns the processing results to the Web server.

CGI is divided into standard CGI and indirect CGI. Standard CGI uses command line parameters or environment variables to represent detailed requests from the server, which communicates with the browser in a standard input and output manner. Indirect CGI, also known as buffer CGI, inserts a buffer program between the CGI program and the CGI interface, which communicates with the standard input and output of the CGI interface.

CGI programs can be written in any language, and almost all servers support CGI as long as they follow CGI communication rules. You can use the compilation languages: C, C, etc.; The MapServer CGI module is a CGI program written in C.

CGI is the most popular tool because of its simplicity. Edit a text-based runtime profile, create a Web page, and then set it to be provided by a Web server, a process that does not require programming.

Early CGI programs ran in separate processes and created a process for each Web request, which was easy to implement but inefficient and difficult to scale. In the face of a large number of requests, the large number of creations and demises of the process significantly degrade operating system performance, and also limit susby resource reuse due to the inability to share address spaces.

FastCGI Introduction

FastCGI is a programming interface, which can accelerate the Web server to call the application’s Web interface, that is, the common gateway interface (CGI). FastCGI is language-independent, it was developed by Open Market, and the copyright belongs to it. The FastCGI standard specification is free to use and provided as an open standard, it provides a single non-proprietary method for use across platforms and any web server.

FastCGI manages multiple CGI requests in one process, saving many program instructions for each request. In the absence of FastCGI, each user instance requesting service will cause the web server to open a new process, the process gains control, executes the service, and then closes. With FastCGI, the overhead of a process is shared among all requests currently being processed. Unlike CGI, which uses FastCGI, processes run independently of the web server, isolating them, thereby providing greater security.

FastCGI is a plugin for web servers. It only requires a few changes to existing server applications, such as Perl or Tcl scripts and C and C ++ programs, to get performance benefits. According to a FastCGI implementer, using FastCGI to handle users’ requests to visit websites and use specific applications can be 3 to 30 times faster.