mod_cgi.html revision 4bc911630ce7a3b965c46e64064a56e127c56793
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync This file is generated from xml source: DO NOT EDIT
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<link href="/style/manual.css" type="text/css" rel="stylesheet">
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<blockquote>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<img alt="[APACHE DOCUMENTATION]" src="/images/sub.gif"><h3>Apache HTTP Server Version 2.0</h3>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<table cellspacing="1" cellpadding="0" bgcolor="#cccccc">
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="module-dict.html#Status" class="help">Status:</a></td><td>Base</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="module-dict.html#ModuleIdentifier" class="help">Module Identifier:</a></td><td>cgi_module</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>Any file that has the mime type
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <code>cgi-script</code> (Apache 1.1 or later) will be treated
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync as a CGI script, and run by the server, with its output being
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync returned to the client. Files acquire this type either by
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync having a name containing an extension defined by the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <code class="directive"><a href="mod_mime.html#addtype" class="directive">AddType</a></code> directive, or by being
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync in a <code class="directive"><a href="mod_alias.html#scriptalias" class="directive">ScriptAlias</a></code>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync directory.</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>When the server invokes a CGI script, it will add a variable
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync called <code>DOCUMENT_ROOT</code> to the environment. This
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync variable will contain the value of the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <code class="directive"><a href="core.html.html#documentroot" class="directive">DocumentRoot</a></code> configuration
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync variable.</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>For an introduction to using CGI scripts with Apache, see
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync our tutorial on <a href="/howto/cgi.html">Dynamic Content
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>When using a multi-threaded MPM under unix, the module
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <code><a href="mod_cgid.html">mod_cgid</a></code> should be used in place of
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync this module. At the user level, the two modules are essentially
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync identical.</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<code class="directive"><a href="core.html#options" class="directive">Options</a></code>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<code class="directive"><a href="mod_alias.html#scriptalias" class="directive">ScriptAlias</a></code>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<code class="directive"><a href="mod_mime.html#addhandler" class="directive">AddHandler</a></code>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>The server will set the CGI environment variables as described
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync in the <a href="http://hoohoo.ncsa.uiuc.edu/cgi/">CGI
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync specification</a>, with the following provisions:</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<dd>This will not be available if the <code class="directive"><a href="core.html#acceptpathinfo" class="directive">AcceptPathInfo</a></code> directive is explicitly set to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <code>off</code>. The default behavior, if AcceptPathInfo is
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync not given, is that mod_cgi will accept path info (trailing
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /more/path/info following the script filename in the URI), while
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync the core server will return a 404 NOT FOUND error for requests
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync with additional path info. Omitting the AcceptPathInfo
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync directive has the same effect as setting it <code>on</code> for
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync mod_cgi requests.</dd>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<dd>This will only be set if <code class="directive"><a href="core.html#hostnamelookups" class="directive">HostnameLookups</a></code> is set to <code>on</code> (it
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync is off by default), and if a reverse DNS lookup of the accessing
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync host's address indeed finds a host name.</dd>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<dd>This will only be set if <code class="directive"><a href="core.html#identitycheck" class="directive">IdentityCheck</a></code> is set to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <code>on</code> and the accessing host supports the ident
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync protocol. Note that the contents of this variable cannot be
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync relied upon because it can easily be faked, and if there is a
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync proxy between the client and the server, it is usually
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync totally useless.</dd>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<dd>This will only be set if the CGI script is subject to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync authentication.</dd>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>Debugging CGI scripts has traditionally been difficult, mainly
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync because it has not been possible to study the output (standard
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync output and error) for scripts which are failing to run
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync properly. These directives, included in Apache 1.2 and later,
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync provide more detailed logging of errors when they occur. </p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>When configured, the CGI error log logs any CGI which does not
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync execute properly. Each CGI script which fails to operate causes
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync several lines of information to be logged. The first two lines
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync are always of the format:</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<blockquote>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %% <em>HTTP-status</em> <em>CGI-script-filename</em>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync</blockquote>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>If the error is that CGI script cannot be run, the log file
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync will contain an extra two lines:</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<blockquote>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %%error<br>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync</blockquote>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>Alternatively, if the error is the result of the script
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync returning incorrect header information (often due to a bug in
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync the script), the following information is logged: </p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<blockquote>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %request<br>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %response<br>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %stdout<br>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %stderr<br>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync</blockquote>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>(The %stdout and %stderr parts may be missing if the script did
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync not output anything on standard output or standard error). </p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<a name="ScriptLog">ScriptLog</a> <a name="scriptlog">Directive</a>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc">
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><strong>Description: </strong></td><td>Location of the CGI script error logfile</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Syntax" class="help">Syntax:</a></td><td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Context" class="help">Context:</a></td><td>server config</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Status" class="help">Status:</a></td><td>Base</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Module" class="help">Module:</a></td><td><code><a href="mod_cgi.html">mod_cgi</a></code>, <code><a href="mod_cgid.html">mod_cgid</a></code></td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>The <code class="directive">ScriptLog</code> directive sets the CGI
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync script error logfile. If no ScriptLog is given, no error log is
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync created. If given, any CGI errors are logged into the filename
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync given as argument. If this is a relative file or path it is taken
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync relative to the server root.</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>This log will be opened as the user the child processes run
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync as, ie. the user specified in the main <code class="directive"><a href="mpm_common.html#user" class="directive">User</a></code> directive. This means that
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync either the directory the script log is in needs to be writable
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync by that user or the file needs to be manually created and set
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync to be writable by that user. If you place the script log in
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync your main logs directory, do <strong>NOT</strong> change the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync directory permissions to make it writable by the user the child
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync processes run as.</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>Note that script logging is meant to be a debugging feature
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync when writing CGI scripts, and is not meant to be activated
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync continuously on running servers. It is not optimized for speed
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync or efficiency, and may have security problems if used in a
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync manner other than that for which it was designed.</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<a name="ScriptLogBuffer">ScriptLogBuffer</a> <a name="scriptlogbuffer">Directive</a>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc">
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><strong>Description: </strong></td><td>Maximum amount of PUT or POST requests that will be recorded
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncin the scriptlog</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Syntax" class="help">Syntax:</a></td><td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Default" class="help">Default:</a></td><td><code>ScriptLogBuffer 1024</code></td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Context" class="help">Context:</a></td><td>server config</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Status" class="help">Status:</a></td><td>Base</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Module" class="help">Module:</a></td><td><code><a href="mod_cgi.html">mod_cgi</a></code>, <code><a href="mod_cgid.html">mod_cgid</a></code></td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<p>The size of any PUT or POST entity body that is logged to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync the file is limited, to prevent the log file growing too big
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync too quickly if large bodies are being received. By default, up
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync to 1024 bytes are logged, but this can be changed with this
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync directive.</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<a name="ScriptLogLength">ScriptLogLength</a> <a name="scriptloglength">Directive</a>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc">
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><strong>Description: </strong></td><td>Size limit of the CGI script logfile</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Syntax" class="help">Syntax:</a></td><td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Default" class="help">Default:</a></td><td><code>ScriptLogLength 10385760</code></td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Context" class="help">Context:</a></td><td>server config</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Status" class="help">Status:</a></td><td>Base</td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<td><a href="directive-dict.html#Module" class="help">Module:</a></td><td><code><a href="mod_cgi.html">mod_cgi</a></code>, <code><a href="mod_cgid.html">mod_cgid</a></code></td>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<code class="directive">ScriptLogLength</code> can be used to limit the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync size of the CGI script logfile. Since the logfile logs a lot of
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync information per CGI error (all request headers, all script output)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync it can grow to be a big file. To prevent problems due to unbounded
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync growth, this directive can be used to set an maximum file-size for
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync the CGI logfile. If the file exceeds this size, no more
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync information will be written to it.</p>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<h3 align="center">Apache HTTP Server Version 2.0</h3>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<a href="./"><img alt="Index" src="/images/index.gif"></a><a href="../"><img alt="Home" src="/images/home.gif"></a>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync</blockquote>