CGI programs are programs that are executed on a Web server. You can use CGI programs for interactive Web access that is not possible when you access only static HTML.
There are three ways to execute CGI programs:
Specify a directory containing CGI programs in the ScriptAlias directive.
Specify the cgi-script handler in the file extension by using the AddHandler directive.
Specify the cgi-script handler in the SetHandler directive.
Hitachi recommends you to set the ScriptAlias directive in httpsd.conf for easy management of CGI programs.
When the CGI program path is <Cosminexus-installation-directory>/httpsd/cgi-bin/CGI program file name, and the clients access the /cgi-bin/CGI program file name
ScriptAlias /cgi-bin/ "<Cosminexus-installation-directory>/httpsd/cgi-bin/" |
AddHandler cgi-script .cgi |
Note that you need to specify the ExecCGI option in the Options directive.
<FilesMatch ^script> |
Invoke CGI programs by specifying a URL from the Web browser in the following format:
http://host-name[:port-number]/path-name[?query-string] |
The Web server passes environment variables to CGI programs. For details, see Appendix B Environment variables passed to CGI programs.
This section describes the sample CGI programs and their execution examples.
#! c:\bin\perl.exe |
http://www.example.com/cgi-bin/test-cgi.pl/ABC?X=1&Y=2 |
This section describes specification methods to pass information, other than the environment variables of CGI/1.1, to CGI programs on the Web server.
You can specify environment variables and their values to be passed to CGI programs in the configuration file. You can also specify environment variables that are not passed to CGI programs:
PassEnv environment variables specification of environment variables to be passed to CGI programs |
You can define environment variables as per client request. You can define environment variables and cancel the settings of environment variables using the host name and IP address of the client, who sends the request.
SetEnvIfNoCase Request_URI "\.(gif)|(jpg)$" request_is_image |
In such cases, if the file extension is .gif or .jpg (this directive is not case sensitive), the environment variable request_is_image is passed to CGI programs.
Standard input, standard output, and standard error output of CGI programs are used to send and receive data between CGI programs and server threads. The Timeout directive is enabled when data is sent and received. When you create CGI programs, after the sending and receiving of data finishes, either close or terminate functionality such as the standard input and output.
When the Web server stops, a CGI program may not end until the process ends. For the forced termination of CGI programs, go to the 'Task manager' and end the program.
In CGI programs, the values specified in User and Group directives require execute permissions.
When the request URL contains the path information to be passed to a CGI program, the environment variable PATH_INFO is set to the path information and the environment variable PATH_TRANSLATED is set to a value that changes the path information into the path on the file system. When you change the path information into a path on the file system, the path specified in the DocumentRoot directive is the base path. For path information, if an optional name is specified in the Alias directive, change the path as per specifications.
According to Web server settings, if the path set in the environment variable PATH_TRANSLATED does not have access permissions, an access denied message is output to the error log. Even when the error message is output, the Web server runs the CGI program and continues the request processing. At this time, the environment variable PATH_TRANSLATED is also passed to the CGI program.
[Fri Feb 20 12:00:00 2004] [error] [client 192.168.1.1] client denied by server configuration: <Cosminexus-installation-directory>/Cosminexus/httpsd/ABC |