1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
4 <!-- English Revision: 1330964:1727201 (outdated) -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <modulesynopsis metafile="mod_cgi.xml.meta">
26 <description>CGI スクリプトの実行</description>
28 <sourcefile>mod_cgi.c</sourcefile>
29 <identifier>cgi_module</identifier>
32 <p>ハンドラ <code>cgi-script</code>
33 が指定されているファイルは CGI スクリプトとして扱われ、
34 サーバにより実行され、その出力がクライアントに返されます。
35 ファイルは、<directive module="mod_mime">AddHandler</directive>
36 ディレクティブに指定された 拡張子を名前に含むか、
37 <directive module="mod_alias">ScriptAlias</directive>
38 ディレクトリに存在することによりこのハンドラになります。</p>
40 <p>Apache で CGI スクリプトを使用するためのイントロダクションは、
41 <a href="../howto/cgi.html">CGI による動的コンテンツ</a>
44 <p>Unix でマルチスレッドの MPM を使っている場合は、このモジュールの
45 代わりに <module>mod_cgid</module> を使う必要があります。
46 ユーザレベルではこの二つのモジュールは本質的には同一です。</p>
48 <p>後方互換性のため、 MIME タイプが <code>application/x-httpd-cgi</code>
49 であるファイルでも cgi-script ハンドラが有効になります。この特殊な MIME タイプを
53 <seealso><directive module="core">AcceptPathInfo</directive></seealso>
54 <seealso><directive module="core">Options</directive> ExecCGI</seealso>
55 <seealso><directive module="mod_alias">ScriptAlias</directive></seealso>
56 <seealso><directive module="mod_mime">AddHandler</directive></seealso>
57 <seealso><a href="../suexec.html">CGI プログラムを別のユーザ ID で実行する</a></seealso>
58 <seealso><a href="http://www.ietf.org/rfc/rfc3875">CGI 規格書</a></seealso>
60 <section id="env"><title>CGI 環境変数</title>
61 <p>サーバは <a href="http://www.ietf.org/rfc/rfc3875">CGI
63 環境変数を設定します。以下のものは、条件付きで設定されます。</p>
68 <dd>これは <directive module="core"
69 >AcceptPathInfo</directive> ディレクティブが明示的に <code>off</code>
70 に設定されている場合は設定されません。デフォルトの、
71 <directive>AcceptPathInfo</directive> が
72 指定されていないときの振る舞いでは、<module>mod_cgi</module> はパス情報
73 (URI のスクリプトのファイル名の後に続く <code>/more/path/info</code>) を
74 受け付けますが、コアはサーバはパス情報のあるリクエストに
75 対して 404 NOT FOUND エラーを返します。<directive>AcceptPathInfo</directive>
77 省略すると、<module>mod_cgi</module> へのリクエストに対して
83 <dd><directive module="core">HostnameLookups</directive>
84 が <code>on</code> (デフォルトでは off です)
85 で、アクセスしているホストのアドレスの DNS
86 の逆引きが実際にホスト名を見つけたときにのみ設定されます。</dd>
90 <dd><directive module="mod_ident">IdentityCheck</directive>
91 が <code>on</code> に設定されていて、アクセスしているホストが
92 ident プロトコルをサポートしているときにのみ設定されます。
93 これは簡単に偽ることができ、クライアントとサーバの間に
95 この変数の値は信用できないということに注意してください。
101 スクリプトに認証が必要なときにのみ設定されます。</dd>
105 <section id="cgi-debug"><title>CGI のデバッグ</title>
106 <p>CGI スクリプトのデバッグは、正しく動作していないスクリプトの出力
108 を調べることができないために、難しい状態が続いていました。
109 これらのディレクティブはより詳細なエラーのログ収集を提供します。</p>
111 <section><title>CGI ログファイルの書式</title>
112 <p>設定されているときには、CGI エラーログは適切に動作しないすべての
113 CGI をログ収集します。それぞれの正しく動作しない CGI
114 スクリプトは 複数の行にわたる情報がログ収集されます。最初の
118 %% [<var>time</var>] <var>request-line</var><br />
119 %% <var>HTTP-status</var> <var>CGI-script-filename</var>
122 <p>エラーが、CGI スクリプトが実行できないというものである場合は、
123 ログファイルはさらにもう 2 行書かれます:</p>
127 <var>error-message</var>
130 <p>そうではなく、エラーが正しくないヘッダ情報を返す結果である場合
131 (スクリプトのバグであることがよくあります)、
136 <var>受け取ったすべての HTTP リクエストヘッダ</var><br />
137 <var>(もしあれば) POST や PUT の中身</var><br />
139 <var>CGI スクリプトにより出力されたすべてのヘッダ</var><br />
141 <var>CGI 標準出力</var><br />
143 <var>CGI 標準エラー</var><br />
146 <p>(スクリプトが標準出力や標準エラーに何も出力しなかった場合は、
147 %stdout や %stderr はありません)。</p>
152 <name>ScriptLog</name>
153 <description>CGI スクリプトのエラーログファイルの場所</description>
154 <syntax>ScriptLog <var>file-path</var></syntax>
155 <contextlist><context>server config</context>
156 <context>virtual host</context>
158 <modulelist><module>mod_cgi</module><module>mod_cgid</module>
162 <p><directive>ScriptLog</directive> ディレクティブは CGI スクリプトの
163 エラーログファイルを設定します。<directive>ScriptLog</directive> が
165 エラーログは作成されません。設定されているときは、CGI
166 のエラーはすべて引数として与えられているファイル名にログされます。
168 <directive module="core">ServerRoot</directive>からの相対パスとして
171 <example><title>例</title>
172 <highlight language="config">
173 ScriptLog logs/cgi_log
177 <p>このログは子プロセスが実行されているユーザとしてオープンされます。
178 <em>すなわち</em>、<directive module="mod_unixd"
179 >User</directive> ディレクティブで指定された
180 ユーザです。これは、スクリプトログが書かれるディレクトリがそのユーザで
181 書き込み可能か、スクリプトファイルが手動で作成され、そのユーザで
182 書き込み可能になっている必要があるということです。スクリプトログを
183 アクセスログなどのためのログディレクトリに書かれるようにしたときは、
184 そのディレクトリを子プロセスを実行しているユーザの権限で
185 書き込み可能には<strong>しない</strong>ようにしてください。</p>
187 <p>スクリプトのログ収集は CGI スクリプトを書くときの
188 デバッグ用の機能として意図されていて、通常のサーバで
189 常に使用されるようには意図されていないということに注意してください。
190 速度や効率は最適化されておらず、設計された以外の方法で使用されると
191 セキュリティの問題があるかもしれません。</p>
196 <name>ScriptLogLength</name>
197 <description>CGI スクリプトのログファイルの大きさの上限</description>
198 <syntax>ScriptLogLength <var>bytes</var></syntax>
199 <default>ScriptLogLength 10385760</default>
200 <contextlist><context>server config</context>
201 <context>virtual host</context>
203 <modulelist><module>mod_cgi</module><module>mod_cgid</module>
207 <p><directive>ScriptLogLength</directive> は CGI スクリプトのログファイル
208 の大きさを制限するために使用することができます。ログファイルは
209 CGI のエラー毎に大量の情報 (リクエストのすべてのヘッダ、
210 すべての出力)をログしますので、すぐに大きなファイルになります。
211 この大きさの制限がないことによる問題を防ぐために、
212 このディレクティブを使って CGI のログファイルの
213 最大のファイルサイズを設定することができます。
214 ファイルがこの大きさを超えた場合は、それ以上は書き込まれません。</p>
219 <name>ScriptLogBuffer</name>
220 <description>スクリプトログに記録される PUT や POST リクエストの内容の上限</description>
221 <syntax>ScriptLogBuffer <em>bytes</em></syntax>
222 <default>ScriptLogBuffer 1024</default>
223 <contextlist><context>server config</context>
224 <context>virtual host</context>
226 <modulelist><module>mod_cgi</module><module>mod_cgid</module>
230 <p>大きな本体を受け取ったときにログファイルがすぐに大きくなりすぎる
231 問題を避けるために、ファイルにログ収集される PUT と POST
232 の本体の大きさは制限されています。デフォルトでは、1024
234 このディレクティブはそれを変更することができます。