summaryrefslogtreecommitdiff
path: root/docs/manual/mod/mod_cgi.xml.ja
blob: eda47f0976bae23a4c7f72cb72b3104501ae520f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
<!-- English Revision: 421174 -->

<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<modulesynopsis metafile="mod_cgi.xml.meta">

<name>mod_cgi</name>
<description>CGI スクリプトの実行</description>
<status>Base</status>
<sourcefile>mod_cgi.c</sourcefile>
<identifier>cgi_module</identifier>

<summary>
    <!-- XXX: Should mention Options ExecCGI
          is the link to howto/cgi not sufficient? -nd
    -->

    <p>Mime タイプが <code>application/x-httpd-cgi</code> 
    であるか、ハンドラ <code>cgi-script</code> (Apache 1.1 以降)
    が指定されているファイルは CGI スクリプトとして扱われ、
    サーバにより実行され、その出力がクライアントに返されます。
    ファイルは、<directive module="mod_mime">AddType</directive>
    ディレクティブに指定された 拡張子を名前に含むか、
    <directive module="mod_alias">ScriptAlias</directive>
    ディレクトリに存在することによりこのタイプになります。</p>

    <p>サーバが CGI スクリプトを実行するときには、
    <code>DOCUMENT_ROOT</code>
    と呼ばれる変数を環境に追加します。この変数は
    <directive module="core">DocumentRoot</directive>
    の値を保持します。</p>

    <p>Apache で CGI スクリプトを使用するためのイントロダクションは、
    <a href="../howto/cgi.html">CGI による動的コンテンツ</a>
    を参照してください。</p>

    <p>Unix でマルチスレッドの MPM を使っている場合は、このモジュールの
    代わりに <module>mod_cgid</module> を使う必要があります。
    ユーザレベルではこの二つのモジュールは本質的には同一です。</p>
</summary>

<seealso><directive module="core">AcceptPathInfo</directive></seealso>
<seealso><directive module="core">Options</directive></seealso>
<seealso><directive module="mod_alias">ScriptAlias</directive></seealso>
<seealso><directive module="mod_mime">AddHandler</directive></seealso>
<seealso><a href="../suexec.html">CGI プログラムを別のユーザ ID で実行する</a></seealso>
<seealso><a href="http://hoohoo.ncsa.uiuc.edu/cgi/">CGI 規格書</a></seealso>

<section id="env"><title>CGI 環境変数</title>
    <p>サーバは <a href="http://hoohoo.ncsa.uiuc.edu/cgi/">CGI
    規格</a> で決められている CGI
    環境変数を設定します。以下のものは、条件付きで設定されます。</p>

    <dl>
      <dt>PATH_INFO</dt>

      <dd>これは <directive module="core"
      >AcceptPathInfo</directive> ディレクティブが明示的に <code>off</code>
      に設定されている場合は設定されません。デフォルトの、
      <directive>AcceptPathInfo</directive> が
      指定されていないときの振る舞いでは、<module>mod_cgi</module> はパス情報
      (URI のスクリプトのファイル名の後に続く <code>/more/path/info</code>) を
      受け付けますが、コアはサーバはパス情報のあるリクエストに
      対して 404 NOT FOUND エラーを返します。<directive>AcceptPathInfo</directive>
      ディレクティブを
      省略すると、<module>mod_cgi</module> へのリクエストに対して
      <code>On</code> を
      設定したのと同じ効果になります。</dd>

      <dt>REMOTE_HOST</dt>

      <dd><directive module="core">HostnameLookups</directive>
      が <code>on</code> (デフォルトでは off です)
      で、アクセスしているホストのアドレスの DNS
      の逆引きが実際にホスト名を見つけたときにのみ設定されます。</dd>

      <dt>REMOTE_IDENT</dt>

      <dd><directive module="core">IdentityCheck</directive>
      が <code>on</code> に設定されていて、アクセスしているホストが
      ident プロトコルをサポートしているときにのみ設定されます。
      これは簡単に偽ることができ、クライアントとサーバの間に
      プロキシがあればまったく役に立たないので、
      この変数の値は信用できないということに注意してください。
      </dd>

      <dt>REMOTE_USER</dt>

      <dd>CGI
      スクリプトに認証が必要なときにのみ設定されます。</dd>
    </dl>
</section>

<section id="cgi-debug"><title>CGI のデバッグ</title>
    <p>CGI スクリプトのデバッグは、正しく動作していないスクリプトの出力
    (標準出力とエラー)
    を調べることができないために、難しい状態が続いていました。
    これらの Apache 1.2 以降にある
    ディレクティブはより詳細なエラーのログ収集を提供します。</p>

    <section><title>CGI ログファイルの書式</title>
	<p>設定されているときには、CGI エラーログは適切に動作しないすべての
	CGI をログ収集します。それぞれの正しく動作しない CGI
	スクリプトは 複数の行にわたる情報がログ収集されます。最初の
	2 行は常に以下の書式です:</p>

      <example>
        %% [<var>time</var>] <var>request-line</var><br />
        %% <var>HTTP-status</var> <var>CGI-script-filename</var>
      </example>

      <p>エラーが、CGI スクリプトが実行できないというものである場合は、
      ログファイルはさらにもう 2 行書かれます:</p>

      <example>
        %%error<br />
        <var>error-message</var>
      </example>

      <p>そうではなく、エラーが正しくないヘッダ情報を返す結果である場合
      (スクリプトのバグであることがよくあります)、
      以下の情報がログ収集されます:</p>

    <example>
      %request<br />
      <var>受け取ったすべての HTTP リクエストヘッダ</var><br />
      <var>(もしあれば) POST や PUT の中身</var><br />
      %response<br />
      <var>CGI スクリプトにより出力されたすべてのヘッダ</var><br />
      %stdout<br />
      <var>CGI 標準出力</var><br />
      %stderr<br />
      <var>CGI 標準エラー</var><br />
    </example>

    <p>(スクリプトが標準出力や標準エラーに何も出力しなかった場合は、
    %stdout や %stderr はありません)。</p>
</section>
</section>

<directivesynopsis>
<name>ScriptLog</name>
<description>CGI スクリプトのエラーログファイルの場所</description>
<syntax>ScriptLog <var>file-path</var></syntax>
<contextlist><context>server config</context>
<context>virtual host</context>
</contextlist>
<modulelist><module>mod_cgi</module><module>mod_cgid</module>
</modulelist>

<usage>
    <p><directive>ScriptLog</directive> ディレクティブは CGI スクリプトの
    エラーログファイルを設定します。<directive>ScriptLog</directive> が
    設定されていないときは、
    エラーログは作成されません。設定されているときは、CGI
    のエラーはすべて引数として与えられているファイル名にログされます。
    相対パスで指定されているときは、
    <directive module="core">ServerRoot</directive>からの相対パスとして
    扱われます。</p>

    <example><title>例</title>
      ScriptLog logs/cgi_log
    </example>

    <p>このログは子プロセスが実行されているユーザとしてオープンされます。
    <em>すなわち</em>、<directive module="mpm_commmon"
    >User</directive> ディレクティブで指定された
    ユーザです。これは、スクリプトログが書かれるディレクトリがそのユーザで
    書き込み可能か、スクリプトファイルが手動で作成され、そのユーザで
    書き込み可能になっている必要があるということです。スクリプトログを
    アクセスログなどのためのログディレクトリに書かれるようにしたときは、
    そのディレクトリを子プロセスを実行しているユーザの権限で
    書き込み可能には<strong>しない</strong>ようにしてください。</p>

    <p>スクリプトのログ収集は CGI スクリプトを書くときの
    デバッグ用の機能として意図されていて、通常のサーバで
    常に使用されるようには意図されていないということに注意してください。
    速度や効率は最適化されておらず、設計された以外の方法で使用されると
    セキュリティの問題があるかもしれません。</p>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>ScriptLogLength</name>
<description>CGI スクリプトのログファイルの大きさの上限</description>
<syntax>ScriptLogLength <var>bytes</var></syntax>
<default>ScriptLogLength 10385760</default>
<contextlist><context>server config</context>
<context>virtual host</context>
</contextlist>
<modulelist><module>mod_cgi</module><module>mod_cgid</module>
</modulelist>

<usage>
    <p><directive>ScriptLogLength</directive> は CGI スクリプトのログファイル
    の大きさを制限するために使用することができます。ログファイルは
    CGI のエラー毎に大量の情報 (リクエストのすべてのヘッダ、
    すべての出力)をログしますので、すぐに大きなファイルになります。
    この大きさの制限がないことによる問題を防ぐために、
    このディレクティブを使って CGI のログファイルの
    最大のファイルサイズを設定することができます。
    ファイルがこの大きさを超えた場合は、それ以上は書き込まれません。</p>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>ScriptLogBuffer</name>
<description>スクリプトログに記録される PUT や POST リクエストの内容の上限</description>
<syntax>ScriptLogBuffer <em>bytes</em></syntax>
<default>ScriptLogBuffer 1024</default>
<contextlist><context>server config</context>
<context>virtual host</context>
</contextlist>
<modulelist><module>mod_cgi</module><module>mod_cgid</module>
</modulelist>

<usage>
    <p>大きな本体を受け取ったときにログファイルがすぐに大きくなりすぎる
    問題を避けるために、ファイルにログ収集される PUT と POST
    の本体の大きさは制限されています。デフォルトでは、1024
    バイトまでがログ収集されますが、
    このディレクティブはそれを変更することができます。 
    </p>
</usage>
</directivesynopsis>

</modulesynopsis>