PREV NEXT

Generic Logic, Inc. www.genlogic.com


Appendix A: Web Server Installation Notes

Introduction

In order to use the Map Server in a web/cgi-bin environment, a web server must be installed. Common web servers include Apache (on both Unix/Linux and Windows) and Internet Information Services - IIS (Windows only). To install a web server, follow its manufacturer's instructions.

The Map Server uses the Common Gateway Interface (CGI), which is supported by most of the web servers. It may also use the FastCGI version of the interface, which allows the map server executable to stay resident in memory and serve multiple map requests, instead of starting and exiting after each request.

In Unix/Linux environment, a bourne shell is used as a scripting language. In Windows environment, a Perl scripting language also needs to be installed, so that the Map Server executable can be invoked by the web server. On Unix systems, a GlmScript bourne shell script that invokes the Map Sever is provided. On Windows, a GlmScript.pl Perl script is provided.

The GlmScript file (GlmScript.pl on Windows) must be placed into the web server's cgi-bin directory. The map server executable and the map data set must be also installed in the location pointed to by the script file.

Unix Notes

The GlmScript shell script provided with the Map Server in the <glg_dir>/map_server/cgi-bin directory should be placed in the cgi-bin directory of the web server. The script source contains step-by-step installation instructions.

If using Apache, cgi-bin scripts usually reside in the /usr/lib/cgi-bin directory. If using a web server other than Apache, see the manufacturers instructions on where cgi-bin scripts are located.

The script must have execute permission for the user that the web server uses to invoke cgi-bin scripts. If a log file is used, it must also have write permissions for that user.

An alternative GlmScript.pl perl script can be used with perl.

Refer to the comments in the scripts for detailed installation instructions.

Windows Notes

The GlmScript.pl perl script provided with the Map Server in the <glg_dir>/map_server/cgi-bin directory should be placed in the scripts directory of the web server. The source of the script contains step-by-step installation instructions.

If using Internet Information Services (IIS), scripts reside in the Scripts directory, which is created by IIS and is usually located at C:\inetpub\wwwroot\Scripts. If using Apache, cgi-bin scripts usually reside in the cgi-bin directory of the Apache installation directory.

The Pearl scripting language must also be installed as described in the following note.

Perl Notes

On Windows, it is not possible to use a batch script to invoke the Map Server, because it is not secure, so a scripting language such as Perl must be installed. A free implementation of Perl can be downloaded at www.activeperl.com. Perl must be installed after the web server so that application bindings are properly installed.

To test if Perl is working properly, create a file test.pl with the following contents:

print "If you are seeing this message, the script executed correctly";
 

Then, from a command prompt on Windows or console session on Unix, execute the following command from the directory where test.pl resides:

perl test.pl
 

If the message in the file is printed, then the script executed correctly.

In order to test if cgi-bin scripts work with the installed web server, create a file called test.pl with the following contents:

print "Content-Type: text/html\n\n";
 
print "If you are seeing this message,<br> the script executed 
correctly";
 

Additionally, if using the Apache web server, the first line of the file must contain #! and the location of the Perl executable.

Place the file into the cgi-bin scripts directory of the web server, change its permissions accordingly, and enter the following URL in a web browser (where mywebserver.com is the location of the webserver):

If running Apache:

http://mywebserver.com/cgi-bin/test.pl
 

If running IIS:

http://mywebserver.com/Scripts/test.pl
 

If the message in the file is printed, then the script executed correctly.

Map Server Setup on a Web Server

Map Server Run-Time Components

The following components are required at run time and need to be copied into the web server's cgi-bin scripts directory:

Make sure GlmMap and GlmScript (or GlmMap.exe and GlmScript.pl) have execute permission.

To debug Map Server setup, create glm_err.log file in the cgi-bin scripts directory (or copy it from <glg_dir>/map_server/cgi-bin directory) and make it writable by the web server's cgi-bin scripts (www-data user and/or group in the default linux/apache configuration). This file will contain the Map Server's error messages. To debug Map Server setup, uncomment lines for extra logging and verbosity in the GlmScript script as described in the next chapter.

Note: The log file debugging output can be used only while debugging map server setup. It should be disabled in the production setup, as it will cause problems when multiple web clients cause simultaneous writing into the log file, resulting in CGI-bin HTTP errors.

GlmScript setup

The GlmScript is an easy-to-edit setup script that connects the web server with the Map Server executable. The script defines the location of the map server executable and its command line options, as well as the location of the GIS data. In addition to serving as a "glue" script, it also hides the details of the specific web setup from the web clients, presenting them with a logical interface to the map generation service.

The setup script starts with comments containing detailed setup instructions as well as sample HTTP requests for testing a map server setup using the sample GIS data. The rest of the setup script contains configuration variables that need to be changed according to the specific web server setup.

While a bourne shell called GlmScript is used in the Unix/Linux environment and a Perl script called GlmScript.pl is used on Windows, the editing instructions are the same for both scripts:

FastCGI setup

FastCGI mode allows the Map Server executable to stay resident in memory and server multiple map requests compared with invoking a separate Map Server executable for each request in CGI mode and exiting when the request is processed. The FastCGI mode not only eliminates excessive executable start-up time, but also speeds up map generation requests by reusing data tiles in Map Server's cache.

In CGI mode, the content of the tile cache is lost when the Map Server executable exits. In the FastCGI mode, consecutive map requests reuse data tiles which have been already read by the previous map requests, saving on the data read time and speeding up map generation. The MAX CACHE SIZE parameter of the LIG file controls the cache size on per-layer basis.

To use the Map Server in the FastCGI environment, edit GlmScript (or GlmScript.pl on Windows) and replace -cgi option with -fcgi , then follow the FastCGI setup instructions for your web server.

Testing Map Server Setup on a Web Server

To test the Map Server's setup, use the sample HTTP map requests listed in the comments section of the GlgScript file, for example on Unix/Linux:

http://my_web_server.com/cgi-bin/GlmScript?VERSION=1.3.0&

REQUEST=GetMap&SRS=EPSG:4326&WIDTH=800&HEIGHT=700&

BBOX=-180,-90,180,90&BGCOLOR=0x0&STYLES=default&

FORMAT=image/jpeg&LAYERS=earth&STRETCH=0
 

or for the Windows-based setup:

http://my_web_server.com/Scripts/GlmScript.pl?VERSION=1.3.0&

REQUEST=GetMap&SRS=EPSG:4326&WIDTH=800&HEIGHT=700&

BBOX=-180,-90,180,90&BGCOLOR=0x0&STYLES=default&

FORMAT=image/jpeg&LAYERS=earth&STRETCH=0
 

Cut and paste one of the map requests into the address field of a web browser, change my_web_server.com to the real domain of your web server and press <Enter>. If everything was setup correctly, the requested map image will appear. Otherwise, an error message will indicate the origin of a problem. If logging is enabled, check the glm_error.log file for more information.

Try changing parameters of the map requests to see how they affect the generated map image.


Generic Logic, Inc.
www.genlogic.com
PREV NEXT