]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_cgi.xml.ja
Merge in APR[-util] macros from branches/trunk-buildconf-noapr
[apache] / docs / manual / mod / mod_cgi.xml.ja
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) -->
5
6 <!--
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
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
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.
21 -->
22
23 <modulesynopsis metafile="mod_cgi.xml.meta">
24
25 <name>mod_cgi</name>
26 <description>CGI スクリプトの実行</description>
27 <status>Base</status>
28 <sourcefile>mod_cgi.c</sourcefile>
29 <identifier>cgi_module</identifier>
30
31 <summary>
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>
39
40     <p>Apache で CGI スクリプトを使用するためのイントロダクションは、
41     <a href="../howto/cgi.html">CGI による動的コンテンツ</a>
42     を参照してください。</p>
43
44     <p>Unix でマルチスレッドの MPM を使っている場合は、このモジュールの
45     代わりに <module>mod_cgid</module> を使う必要があります。
46     ユーザレベルではこの二つのモジュールは本質的には同一です。</p>
47
48     <p>後方互換性のため、 MIME タイプが <code>application/x-httpd-cgi</code> 
49     であるファイルでも cgi-script ハンドラが有効になります。この特殊な MIME タイプを
50     使う方法は非推奨です。</p> 
51 </summary>
52
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>
59
60 <section id="env"><title>CGI 環境変数</title>
61     <p>サーバは <a href="http://www.ietf.org/rfc/rfc3875">CGI
62     規格</a> で決められている CGI
63     環境変数を設定します。以下のものは、条件付きで設定されます。</p>
64
65     <dl>
66       <dt>PATH_INFO</dt>
67
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>
76       ディレクティブを
77       省略すると、<module>mod_cgi</module> へのリクエストに対して
78       <code>On</code> を
79       設定したのと同じ効果になります。</dd>
80
81       <dt>REMOTE_HOST</dt>
82
83       <dd><directive module="core">HostnameLookups</directive>
84       が <code>on</code> (デフォルトでは off です)
85       で、アクセスしているホストのアドレスの DNS
86       の逆引きが実際にホスト名を見つけたときにのみ設定されます。</dd>
87
88       <dt>REMOTE_IDENT</dt>
89
90       <dd><directive module="mod_ident">IdentityCheck</directive>
91       が <code>on</code> に設定されていて、アクセスしているホストが
92       ident プロトコルをサポートしているときにのみ設定されます。
93       これは簡単に偽ることができ、クライアントとサーバの間に
94       プロキシがあればまったく役に立たないので、
95       この変数の値は信用できないということに注意してください。
96       </dd>
97
98       <dt>REMOTE_USER</dt>
99
100       <dd>CGI
101       スクリプトに認証が必要なときにのみ設定されます。</dd>
102     </dl>
103 </section>
104
105 <section id="cgi-debug"><title>CGI のデバッグ</title>
106     <p>CGI スクリプトのデバッグは、正しく動作していないスクリプトの出力
107     (標準出力とエラー)
108     を調べることができないために、難しい状態が続いていました。
109     これらのディレクティブはより詳細なエラーのログ収集を提供します。</p>
110
111     <section><title>CGI ログファイルの書式</title>
112         <p>設定されているときには、CGI エラーログは適切に動作しないすべての
113         CGI をログ収集します。それぞれの正しく動作しない CGI
114         スクリプトは 複数の行にわたる情報がログ収集されます。最初の
115         2 行は常に以下の書式です:</p>
116
117       <example>
118         %% [<var>time</var>] <var>request-line</var><br />
119         %% <var>HTTP-status</var> <var>CGI-script-filename</var>
120       </example>
121
122       <p>エラーが、CGI スクリプトが実行できないというものである場合は、
123       ログファイルはさらにもう 2 行書かれます:</p>
124
125       <example>
126         %%error<br />
127         <var>error-message</var>
128       </example>
129
130       <p>そうではなく、エラーが正しくないヘッダ情報を返す結果である場合
131       (スクリプトのバグであることがよくあります)、
132       以下の情報がログ収集されます:</p>
133
134     <example>
135       %request<br />
136       <var>受け取ったすべての HTTP リクエストヘッダ</var><br />
137       <var>(もしあれば) POST や PUT の中身</var><br />
138       %response<br />
139       <var>CGI スクリプトにより出力されたすべてのヘッダ</var><br />
140       %stdout<br />
141       <var>CGI 標準出力</var><br />
142       %stderr<br />
143       <var>CGI 標準エラー</var><br />
144     </example>
145
146     <p>(スクリプトが標準出力や標準エラーに何も出力しなかった場合は、
147     %stdout や %stderr はありません)。</p>
148 </section>
149 </section>
150
151 <directivesynopsis>
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>
157 </contextlist>
158 <modulelist><module>mod_cgi</module><module>mod_cgid</module>
159 </modulelist>
160
161 <usage>
162     <p><directive>ScriptLog</directive> ディレクティブは CGI スクリプトの
163     エラーログファイルを設定します。<directive>ScriptLog</directive> が
164     設定されていないときは、
165     エラーログは作成されません。設定されているときは、CGI
166     のエラーはすべて引数として与えられているファイル名にログされます。
167     相対パスで指定されているときは、
168     <directive module="core">ServerRoot</directive>からの相対パスとして
169     扱われます。</p>
170
171     <example><title>例</title>
172     <highlight language="config">
173       ScriptLog logs/cgi_log
174     </highlight>
175     </example>
176
177     <p>このログは子プロセスが実行されているユーザとしてオープンされます。
178     <em>すなわち</em>、<directive module="mod_unixd"
179     >User</directive> ディレクティブで指定された
180     ユーザです。これは、スクリプトログが書かれるディレクトリがそのユーザで
181     書き込み可能か、スクリプトファイルが手動で作成され、そのユーザで
182     書き込み可能になっている必要があるということです。スクリプトログを
183     アクセスログなどのためのログディレクトリに書かれるようにしたときは、
184     そのディレクトリを子プロセスを実行しているユーザの権限で
185     書き込み可能には<strong>しない</strong>ようにしてください。</p>
186
187     <p>スクリプトのログ収集は CGI スクリプトを書くときの
188     デバッグ用の機能として意図されていて、通常のサーバで
189     常に使用されるようには意図されていないということに注意してください。
190     速度や効率は最適化されておらず、設計された以外の方法で使用されると
191     セキュリティの問題があるかもしれません。</p>
192 </usage>
193 </directivesynopsis>
194
195 <directivesynopsis>
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>
202 </contextlist>
203 <modulelist><module>mod_cgi</module><module>mod_cgid</module>
204 </modulelist>
205
206 <usage>
207     <p><directive>ScriptLogLength</directive> は CGI スクリプトのログファイル
208     の大きさを制限するために使用することができます。ログファイルは
209     CGI のエラー毎に大量の情報 (リクエストのすべてのヘッダ、
210     すべての出力)をログしますので、すぐに大きなファイルになります。
211     この大きさの制限がないことによる問題を防ぐために、
212     このディレクティブを使って CGI のログファイルの
213     最大のファイルサイズを設定することができます。
214     ファイルがこの大きさを超えた場合は、それ以上は書き込まれません。</p>
215 </usage>
216 </directivesynopsis>
217
218 <directivesynopsis>
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>
225 </contextlist>
226 <modulelist><module>mod_cgi</module><module>mod_cgid</module>
227 </modulelist>
228
229 <usage>
230     <p>大きな本体を受け取ったときにログファイルがすぐに大きくなりすぎる
231     問題を避けるために、ファイルにログ収集される PUT と POST
232     の本体の大きさは制限されています。デフォルトでは、1024
233     バイトまでがログ収集されますが、
234     このディレクティブはそれを変更することができます。 
235     </p>
236 </usage>
237 </directivesynopsis>
238
239 </modulesynopsis>