mod_cgi.html.en revision 8574d86b9ec3be36b7f54ed0547a0ee5d60dbd6b
b51bf223f42d43ca6b1b33c95124edcfa5a871a4nd<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
9963f91528694fb21e93da8584c31f226c6de97akess<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
d78d735dbf7c5ce5ae545eecd8ee2c052224db77nd XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
dba4cfbd6e9a1f639fb6831d1bca86bef6bf8506nd This file is generated from xml source: DO NOT EDIT
031b91a62d25106ae69d4693475c79618dd5e884fielding XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
031b91a62d25106ae69d4693475c79618dd5e884fielding<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
031b91a62d25106ae69d4693475c79618dd5e884fielding<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
031b91a62d25106ae69d4693475c79618dd5e884fielding<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
dba4cfbd6e9a1f639fb6831d1bca86bef6bf8506nd<link href="/images/favicon.ico" rel="shortcut icon" /></head>
dba4cfbd6e9a1f639fb6831d1bca86bef6bf8506nd<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
dba4cfbd6e9a1f639fb6831d1bca86bef6bf8506nd<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
dba4cfbd6e9a1f639fb6831d1bca86bef6bf8506nd<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.1</a> > <a href="./">Modules</a></div>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<p><span>Available Languages: </span><a href="/en/mod/mod_cgi.html"> en </a> | <a href="/ja/mod/mod_cgi.html"> ja </a> | <a href="/ko/mod/mod_cgi.html"> ko </a></p>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Execution of CGI scripts</td></tr>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>cgi_module</td></tr>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_cgi.c</td></tr></table>
eed2a23d9b5986937f1e2b1c120be97744508a72nd <p>Any file that has the mime type
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <code>cgi-script</code> (Apache 1.1 or later) will be treated
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak as a CGI script, and run by the server, with its output being
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak returned to the client. Files acquire this type either by
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak having a name containing an extension defined by the
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <code class="directive"><a href="/mod/mod_mime.html#addtype">AddType</a></code> directive, or by being
eed2a23d9b5986937f1e2b1c120be97744508a72nd in a <code class="directive"><a href="/mod/mod_alias.html#scriptalias">ScriptAlias</a></code>
eed2a23d9b5986937f1e2b1c120be97744508a72nd directory.</p>
eed2a23d9b5986937f1e2b1c120be97744508a72nd <p>When the server invokes a CGI script, it will add a variable
eed2a23d9b5986937f1e2b1c120be97744508a72nd called <code>DOCUMENT_ROOT</code> to the environment. This
eed2a23d9b5986937f1e2b1c120be97744508a72nd variable will contain the value of the
61d237f7e3a54089a7514227d663fac296d7d8f0bnicholes <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code> configuration
eed2a23d9b5986937f1e2b1c120be97744508a72nd variable.</p>
eed2a23d9b5986937f1e2b1c120be97744508a72nd <p>For an introduction to using CGI scripts with Apache, see
eed2a23d9b5986937f1e2b1c120be97744508a72nd our tutorial on <a href="/howto/cgi.html">Dynamic Content
eed2a23d9b5986937f1e2b1c120be97744508a72nd <p>When using a multi-threaded MPM under unix, the module
eed2a23d9b5986937f1e2b1c120be97744508a72nd <code class="module"><a href="/mod/mod_cgid.html">mod_cgid</a></code> should be used in place of
eed2a23d9b5986937f1e2b1c120be97744508a72nd this module. At the user level, the two modules are essentially
eed2a23d9b5986937f1e2b1c120be97744508a72nd identical.</p>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<div id="quickview"><h3 class="directives">Directives</h3>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><img alt="" src="/images/down.gif" /> <a href="#scriptlog">ScriptLog</a></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><img alt="" src="/images/down.gif" /> <a href="#scriptlogbuffer">ScriptLogBuffer</a></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><img alt="" src="/images/down.gif" /> <a href="#scriptloglength">ScriptLogLength</a></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><img alt="" src="/images/down.gif" /> <a href="#env">CGI Environment variables</a></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><img alt="" src="/images/down.gif" /> <a href="#cgi-debug">CGI Debugging</a></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><code class="directive"><a href="/mod/core.html#acceptpathinfo">AcceptPathInfo</a></code></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><code class="directive"><a href="/mod/core.html#options">Options</a></code></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><code class="directive"><a href="/mod/mod_alias.html#scriptalias">ScriptAlias</a></code></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><code class="directive"><a href="/mod/mod_mime.html#addhandler">AddHandler</a></code></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><a href="/suexec.html">Running CGI programs under different user IDs</a></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<li><a href="http://hoohoo.ncsa.uiuc.edu/cgi/">CGI Specification</a></li>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd<h2><a name="env" id="env">CGI Environment variables</a></h2>
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd <p>The server will set the CGI environment variables as described
eed2a23d9b5986937f1e2b1c120be97744508a72nd <dd>This will not be available if the <code class="directive"><a href="/mod/core.html#acceptpathinfo">AcceptPathInfo</a></code> directive is explicitly set to
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd <code>off</code>. The default behavior, if <code class="directive">AcceptPathInfo</code> is not given, is that <code class="module"><a href="/mod/mod_cgi.html">mod_cgi</a></code> will accept path info (trailing <code>
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd /more/path/info</code> following the script filename in the URI),
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd while the core server will return a 404 NOT FOUND error for requests
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd with additional path info. Omitting the <code class="directive">AcceptPathInfo</code> directive has the same effect as setting
eed2a23d9b5986937f1e2b1c120be97744508a72nd it <code>On</code> for <code class="module"><a href="/mod/mod_cgi.html">mod_cgi</a></code> requests.</dd>
eed2a23d9b5986937f1e2b1c120be97744508a72nd <dd>This will only be set if <code class="directive"><a href="/mod/core.html#hostnamelookups">HostnameLookups</a></code> is set to <code>on</code> (it
eed2a23d9b5986937f1e2b1c120be97744508a72nd is off by default), and if a reverse DNS lookup of the accessing
eed2a23d9b5986937f1e2b1c120be97744508a72nd host's address indeed finds a host name.</dd>
eed2a23d9b5986937f1e2b1c120be97744508a72nd <dd>This will only be set if <code class="directive"><a href="/mod/core.html#identitycheck">IdentityCheck</a></code> is set to
eed2a23d9b5986937f1e2b1c120be97744508a72nd <code>on</code> and the accessing host supports the ident
eed2a23d9b5986937f1e2b1c120be97744508a72nd protocol. Note that the contents of this variable cannot be
9963f91528694fb21e93da8584c31f226c6de97akess relied upon because it can easily be faked, and if there is a
9963f91528694fb21e93da8584c31f226c6de97akess proxy between the client and the server, it is usually
9963f91528694fb21e93da8584c31f226c6de97akess totally useless.</dd>
eed2a23d9b5986937f1e2b1c120be97744508a72nd <dd>This will only be set if the CGI script is subject to
eed2a23d9b5986937f1e2b1c120be97744508a72nd authentication.</dd>
b51bf223f42d43ca6b1b33c95124edcfa5a871a4nd</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
eed2a23d9b5986937f1e2b1c120be97744508a72nd<h2><a name="cgi-debug" id="cgi-debug">CGI Debugging</a></h2>
eed2a23d9b5986937f1e2b1c120be97744508a72nd <p>Debugging CGI scripts has traditionally been difficult, mainly
eed2a23d9b5986937f1e2b1c120be97744508a72nd because it has not been possible to study the output (standard
eed2a23d9b5986937f1e2b1c120be97744508a72nd output and error) for scripts which are failing to run
eed2a23d9b5986937f1e2b1c120be97744508a72nd properly. These directives, included in Apache 1.2 and later,
eed2a23d9b5986937f1e2b1c120be97744508a72nd provide more detailed logging of errors when they occur.</p>
b51bf223f42d43ca6b1b33c95124edcfa5a871a4nd <p>When configured, the CGI error log logs any CGI which does not
eed2a23d9b5986937f1e2b1c120be97744508a72nd execute properly. Each CGI script which fails to operate causes
eed2a23d9b5986937f1e2b1c120be97744508a72nd several lines of information to be logged. The first two lines
eed2a23d9b5986937f1e2b1c120be97744508a72nd are always of the format:</p>
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd <p>If the error is that CGI script cannot be run, the log file
eed2a23d9b5986937f1e2b1c120be97744508a72nd will contain an extra two lines:</p>
eed2a23d9b5986937f1e2b1c120be97744508a72nd %%error<br />
<div class="directive-section"><h2><a name="ScriptLog" id="ScriptLog">ScriptLog</a> <a name="scriptlog" id="scriptlog">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Location of the CGI script error logfile</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptLog <var>file-path</var></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td><code class="module"><a href="/mod/mod_cgi.html">mod_cgi</a></code>, <code class="module"><a href="/mod/mod_cgid.html">mod_cgid</a></code></td></tr>
taken relative to the <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code>.
as, <em>i.e.</em> the user specified in the main <code class="directive"><a href="/mod/mpm_common.html#user">User</a></code> directive. This means that
<div class="directive-section"><h2><a name="ScriptLogBuffer" id="ScriptLogBuffer">ScriptLogBuffer</a> <a name="scriptlogbuffer" id="scriptlogbuffer">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maximum amount of PUT or POST requests that will be recorded
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptLogBuffer <var>bytes</var></code></td></tr>
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>ScriptLogBuffer 1024</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td><code class="module"><a href="/mod/mod_cgi.html">mod_cgi</a></code>, <code class="module"><a href="/mod/mod_cgid.html">mod_cgid</a></code></td></tr>
<div class="directive-section"><h2><a name="ScriptLogLength" id="ScriptLogLength">ScriptLogLength</a> <a name="scriptloglength" id="scriptloglength">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Size limit of the CGI script logfile</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptLogLength <var>bytes</var></code></td></tr>
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>ScriptLogLength 10385760</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td><code class="module"><a href="/mod/mod_cgi.html">mod_cgi</a></code>, <code class="module"><a href="/mod/mod_cgid.html">mod_cgid</a></code></td></tr>
<p><span>Available Languages: </span><a href="/en/mod/mod_cgi.html"> en </a> | <a href="/ja/mod/mod_cgi.html"> ja </a> | <a href="/ko/mod/mod_cgi.html"> ko </a></p>
<p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>