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: 558718:1061423 (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 <!-- XXX: Should mention Options ExecCGI
33 is the link to howto/cgi not sufficient? -nd
36 <p>ハンドラ <code>cgi-script</code>
37 が指定されているファイルは CGI スクリプトとして扱われ、
38 サーバにより実行され、その出力がクライアントに返されます。
39 ファイルは、<directive module="mod_mime">AddHandler</directive>
40 ディレクティブに指定された 拡張子を名前に含むか、
41 <directive module="mod_alias">ScriptAlias</directive>
42 ディレクトリに存在することによりこのハンドラになります。</p>
44 <p>Apache で CGI スクリプトを使用するためのイントロダクションは、
45 <a href="../howto/cgi.html">CGI による動的コンテンツ</a>
48 <p>Unix でマルチスレッドの MPM を使っている場合は、このモジュールの
49 代わりに <module>mod_cgid</module> を使う必要があります。
50 ユーザレベルではこの二つのモジュールは本質的には同一です。</p>
52 <p>後方互換性のため、 MIME タイプが <code>application/x-httpd-cgi</code>
53 であるファイルでも cgi-script ハンドラが有効になります。この特殊な MIME タイプを
57 <seealso><directive module="core">AcceptPathInfo</directive></seealso>
58 <seealso><directive module="core">Options</directive></seealso>
59 <seealso><directive module="mod_alias">ScriptAlias</directive></seealso>
60 <seealso><directive module="mod_mime">AddHandler</directive></seealso>
61 <seealso><a href="../suexec.html">CGI プログラムを別のユーザ ID で実行する</a></seealso>
62 <seealso><a href="http://hoohoo.ncsa.uiuc.edu/cgi/">CGI 規格書</a></seealso>
64 <section id="env"><title>CGI 環境変数</title>
65 <p>サーバは <a href="http://hoohoo.ncsa.uiuc.edu/cgi/">CGI
67 環境変数を設定します。以下のものは、条件付きで設定されます。</p>
72 <dd>これは <directive module="core"
73 >AcceptPathInfo</directive> ディレクティブが明示的に <code>off</code>
74 に設定されている場合は設定されません。デフォルトの、
75 <directive>AcceptPathInfo</directive> が
76 指定されていないときの振る舞いでは、<module>mod_cgi</module> はパス情報
77 (URI のスクリプトのファイル名の後に続く <code>/more/path/info</code>) を
78 受け付けますが、コアはサーバはパス情報のあるリクエストに
79 対して 404 NOT FOUND エラーを返します。<directive>AcceptPathInfo</directive>
81 省略すると、<module>mod_cgi</module> へのリクエストに対して
87 <dd><directive module="core">HostnameLookups</directive>
88 が <code>on</code> (デフォルトでは off です)
89 で、アクセスしているホストのアドレスの DNS
90 の逆引きが実際にホスト名を見つけたときにのみ設定されます。</dd>
94 <dd><directive module="core">IdentityCheck</directive>
95 が <code>on</code> に設定されていて、アクセスしているホストが
96 ident プロトコルをサポートしているときにのみ設定されます。
97 これは簡単に偽ることができ、クライアントとサーバの間に
99 この変数の値は信用できないということに注意してください。
105 スクリプトに認証が必要なときにのみ設定されます。</dd>
109 <section id="cgi-debug"><title>CGI のデバッグ</title>
110 <p>CGI スクリプトのデバッグは、正しく動作していないスクリプトの出力
112 を調べることができないために、難しい状態が続いていました。
113 これらの Apache 1.2 以降にある
114 ディレクティブはより詳細なエラーのログ収集を提供します。</p>
116 <section><title>CGI ログファイルの書式</title>
117 <p>設定されているときには、CGI エラーログは適切に動作しないすべての
118 CGI をログ収集します。それぞれの正しく動作しない CGI
119 スクリプトは 複数の行にわたる情報がログ収集されます。最初の
123 %% [<var>time</var>] <var>request-line</var><br />
124 %% <var>HTTP-status</var> <var>CGI-script-filename</var>
127 <p>エラーが、CGI スクリプトが実行できないというものである場合は、
128 ログファイルはさらにもう 2 行書かれます:</p>
132 <var>error-message</var>
135 <p>そうではなく、エラーが正しくないヘッダ情報を返す結果である場合
136 (スクリプトのバグであることがよくあります)、
141 <var>受け取ったすべての HTTP リクエストヘッダ</var><br />
142 <var>(もしあれば) POST や PUT の中身</var><br />
144 <var>CGI スクリプトにより出力されたすべてのヘッダ</var><br />
146 <var>CGI 標準出力</var><br />
148 <var>CGI 標準エラー</var><br />
151 <p>(スクリプトが標準出力や標準エラーに何も出力しなかった場合は、
152 %stdout や %stderr はありません)。</p>
157 <name>ScriptLog</name>
158 <description>CGI スクリプトのエラーログファイルの場所</description>
159 <syntax>ScriptLog <var>file-path</var></syntax>
160 <contextlist><context>server config</context>
161 <context>virtual host</context>
163 <modulelist><module>mod_cgi</module><module>mod_cgid</module>
167 <p><directive>ScriptLog</directive> ディレクティブは CGI スクリプトの
168 エラーログファイルを設定します。<directive>ScriptLog</directive> が
170 エラーログは作成されません。設定されているときは、CGI
171 のエラーはすべて引数として与えられているファイル名にログされます。
173 <directive module="core">ServerRoot</directive>からの相対パスとして
176 <example><title>例</title>
177 ScriptLog logs/cgi_log
180 <p>このログは子プロセスが実行されているユーザとしてオープンされます。
181 <em>すなわち</em>、<directive module="mpm_commmon"
182 >User</directive> ディレクティブで指定された
183 ユーザです。これは、スクリプトログが書かれるディレクトリがそのユーザで
184 書き込み可能か、スクリプトファイルが手動で作成され、そのユーザで
185 書き込み可能になっている必要があるということです。スクリプトログを
186 アクセスログなどのためのログディレクトリに書かれるようにしたときは、
187 そのディレクトリを子プロセスを実行しているユーザの権限で
188 書き込み可能には<strong>しない</strong>ようにしてください。</p>
190 <p>スクリプトのログ収集は CGI スクリプトを書くときの
191 デバッグ用の機能として意図されていて、通常のサーバで
192 常に使用されるようには意図されていないということに注意してください。
193 速度や効率は最適化されておらず、設計された以外の方法で使用されると
194 セキュリティの問題があるかもしれません。</p>
199 <name>ScriptLogLength</name>
200 <description>CGI スクリプトのログファイルの大きさの上限</description>
201 <syntax>ScriptLogLength <var>bytes</var></syntax>
202 <default>ScriptLogLength 10385760</default>
203 <contextlist><context>server config</context>
204 <context>virtual host</context>
206 <modulelist><module>mod_cgi</module><module>mod_cgid</module>
210 <p><directive>ScriptLogLength</directive> は CGI スクリプトのログファイル
211 の大きさを制限するために使用することができます。ログファイルは
212 CGI のエラー毎に大量の情報 (リクエストのすべてのヘッダ、
213 すべての出力)をログしますので、すぐに大きなファイルになります。
214 この大きさの制限がないことによる問題を防ぐために、
215 このディレクティブを使って CGI のログファイルの
216 最大のファイルサイズを設定することができます。
217 ファイルがこの大きさを超えた場合は、それ以上は書き込まれません。</p>
222 <name>ScriptLogBuffer</name>
223 <description>スクリプトログに記録される PUT や POST リクエストの内容の上限</description>
224 <syntax>ScriptLogBuffer <em>bytes</em></syntax>
225 <default>ScriptLogBuffer 1024</default>
226 <contextlist><context>server config</context>
227 <context>virtual host</context>
229 <modulelist><module>mod_cgi</module><module>mod_cgid</module>
233 <p>大きな本体を受け取ったときにログファイルがすぐに大きくなりすぎる
234 問題を避けるために、ファイルにログ収集される PUT と POST
235 の本体の大きさは制限されています。デフォルトでは、1024
237 このディレクティブはそれを変更することができます。