mod_cgi.xml revision 4bc911630ce7a3b965c46e64064a56e127c56793
eca1144dc479593f288406c5135a8b71d02c36c5kess<?xml-stylesheet type="text/xsl" href="/style/manual.xsl"?>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf<modulesynopsis>
a3d2b657dd7ca66251b562b6a82c2335135b9172nd <!-- XXX: Should have references to CGI definition/RFC -->
a3d2b657dd7ca66251b562b6a82c2335135b9172nd <!-- XXX: Should mention Options ExecCGI -->
a3d2b657dd7ca66251b562b6a82c2335135b9172nd <!-- XXX: Should mention AcceptPathInfo -->
a3d2b657dd7ca66251b562b6a82c2335135b9172nd <p>Any file that has the mime type
a3d2b657dd7ca66251b562b6a82c2335135b9172nd <code>cgi-script</code> (Apache 1.1 or later) will be treated
a3d2b657dd7ca66251b562b6a82c2335135b9172nd as a CGI script, and run by the server, with its output being
a3d2b657dd7ca66251b562b6a82c2335135b9172nd returned to the client. Files acquire this type either by
a3d2b657dd7ca66251b562b6a82c2335135b9172nd having a name containing an extension defined by the
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <directive module="mod_mime">AddType</directive> directive, or by being
d9ef684564c53b70e20e0d8a98aa721687cf2605kess in a <directive module="mod_alias">ScriptAlias</directive>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess directory.</p>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <p>When the server invokes a CGI script, it will add a variable
d9ef684564c53b70e20e0d8a98aa721687cf2605kess called <code>DOCUMENT_ROOT</code> to the environment. This
d9ef684564c53b70e20e0d8a98aa721687cf2605kess variable will contain the value of the
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <directive module="core.html">DocumentRoot</directive> configuration
d9ef684564c53b70e20e0d8a98aa721687cf2605kess variable.</p>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <p>For an introduction to using CGI scripts with Apache, see
d9ef684564c53b70e20e0d8a98aa721687cf2605kess our tutorial on <a href="/howto/cgi.html">Dynamic Content
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <p>When using a multi-threaded MPM under unix, the module
d9ef684564c53b70e20e0d8a98aa721687cf2605kess this module. At the user level, the two modules are essentially
d9ef684564c53b70e20e0d8a98aa721687cf2605kess identical.</p>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess<seealso><directive module="core">Options</directive></seealso>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess<seealso><directive module="mod_alias">ScriptAlias</directive></seealso>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess<seealso><directive module="mod_mime">AddHandler</directive></seealso>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <p>The server will set the CGI environment variables as described
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <dd>This will not be available if the <directive module="core"
d9ef684564c53b70e20e0d8a98aa721687cf2605kess >AcceptPathInfo</directive> directive is explicitly set to
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <code>off</code>. The default behavior, if AcceptPathInfo is
d9ef684564c53b70e20e0d8a98aa721687cf2605kess not given, is that mod_cgi will accept path info (trailing
d9ef684564c53b70e20e0d8a98aa721687cf2605kess /more/path/info following the script filename in the URI), while
d9ef684564c53b70e20e0d8a98aa721687cf2605kess the core server will return a 404 NOT FOUND error for requests
d9ef684564c53b70e20e0d8a98aa721687cf2605kess with additional path info. Omitting the AcceptPathInfo
d9ef684564c53b70e20e0d8a98aa721687cf2605kess directive has the same effect as setting it <code>on</code> for
d9ef684564c53b70e20e0d8a98aa721687cf2605kess mod_cgi requests.</dd>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess >HostnameLookups</directive> is set to <code>on</code> (it
d9ef684564c53b70e20e0d8a98aa721687cf2605kess is off by default), and if a reverse DNS lookup of the accessing
d9ef684564c53b70e20e0d8a98aa721687cf2605kess host's address indeed finds a host name.</dd>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess >IdentityCheck</directive> is set to
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <code>on</code> and the accessing host supports the ident
d9ef684564c53b70e20e0d8a98aa721687cf2605kess protocol. Note that the contents of this variable cannot be
d9ef684564c53b70e20e0d8a98aa721687cf2605kess relied upon because it can easily be faked, and if there is a
d9ef684564c53b70e20e0d8a98aa721687cf2605kess proxy between the client and the server, it is usually
d9ef684564c53b70e20e0d8a98aa721687cf2605kess totally useless.</dd>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <dd>This will only be set if the CGI script is subject to
d9ef684564c53b70e20e0d8a98aa721687cf2605kess authentication.</dd>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <p>Debugging CGI scripts has traditionally been difficult, mainly
d9ef684564c53b70e20e0d8a98aa721687cf2605kess because it has not been possible to study the output (standard
d9ef684564c53b70e20e0d8a98aa721687cf2605kess output and error) for scripts which are failing to run
d9ef684564c53b70e20e0d8a98aa721687cf2605kess properly. These directives, included in Apache 1.2 and later,
d9ef684564c53b70e20e0d8a98aa721687cf2605kess provide more detailed logging of errors when they occur. </p>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <p>When configured, the CGI error log logs any CGI which does not
d9ef684564c53b70e20e0d8a98aa721687cf2605kess execute properly. Each CGI script which fails to operate causes
d9ef684564c53b70e20e0d8a98aa721687cf2605kess several lines of information to be logged. The first two lines
d9ef684564c53b70e20e0d8a98aa721687cf2605kess are always of the format:</p>
d9ef684564c53b70e20e0d8a98aa721687cf2605kess <p>If the error is that CGI script cannot be run, the log file
d9ef684564c53b70e20e0d8a98aa721687cf2605kess will contain an extra two lines:</p>