This file is indexed.

/usr/share/doc/python-scgi/guide.html is in python-scgi 1.13-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
<?xml version="1.0" encoding="us-ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="CONTENT-TYPE" content="text/html; charset=us-ascii" />
    <title>SCGI Guide</title>
    <style type="text/css">
/*<![CDATA[*/
        <!--
                @page { margin: 0.79in }
        -->
/*]]>*/
</style>
  </head>
  <body lang="en-GB" xml:lang="en-GB">
    <h1>Using SCGI with Apache 2.x and Python</h1>
    <p>This guide describes how to use SCGI with Apache 2.x, to serve an
        application written in Python. The SCGI package also comes with modules
        to use the protocol with Apache 1.x or <tt>lighttpd</tt>, and
        frameworks for applications in other languages are available (including
        LISP).</p>
    <p>A complete setup for an SCGI application involves these four
        components:</p>
    <ol>
      <li>
        <p style="margin-bottom: 0in">A web server to process incoming
            <tt>http</tt> requests--in our case, Apache 2.</p>
      </li>
      <li>
        <p style="margin-bottom: 0in">The Apache SCGI module to delegate
            requests over the SCGI protocol.</p>
      </li>
      <li>
        <p style="margin-bottom: 0in">An SCGI server process based on the
            Python <tt>scgi_server</tt> module.</p>
      </li>
      <li>
        <p>An application to be run in child processes forked off by the
            server process.</p>
      </li>
    </ol>
    <p>A single SCGI server process serves only one application, but
        multiple instances of it. Each instance lives in its own child process
        of the SCGI server. More child processes are created on demand.</p>
    <h2>Apache module</h2>
    <p>To install the module by hand, <tt>cd</tt> into the <tt>apache2</tt>
        subdirectory of the SCGI source tree, and, as root, <tt>make
        install</tt>. On Debian-based systems and Gentoo, however, just install
        the <tt>libapache2-mod-scgi</tt> package. RPM users can install
        <tt>apache2-mod_scgi</tt>.</p>
    <p>Next, set up the webserver to load the module and delegate requests
        (in this example, for the <tt>http</tt> path "<tt>/dynamic</tt>") to a
        separate server process accepting SCGI requests over a TCP socket. That
        server will typically run on the same machine as the <tt>http</tt>
        server, but it doesn't have to. Here's a snippet of Apache 2 config to
        delegate requests for the <tt>http</tt> path <tt>/dynamic</tt> to local
        TCP port 4000, which is the default:</p>
    <pre>
# (This actually better set up permanently with the command line
# "a2enmod scgi" but shown here for completeness)
LoadModule scgi_module /usr/lib/apache2/modules/mod_scgi.so

# Set up a location to be served by an SCGI server process
SCGIMount /dynamic/ 127.0.0.1:4000
</pre>
    <p>The deprecated way of delegating requests to an SCGI server
	is as follows:</p>
    <pre>
&lt;Location "/dynamic"&gt;
    # Enable SCGI delegation
    SCGIHandler On
    # Delegate requests in the "/dynamic" path to daemon on local
    # server, port 4000
    SCGIServer 127.0.0.1:4000
&lt;/Location&gt;
</pre>
    <p>Note that using <tt>SCGIMount</tt> instead of <tt>SCGIServer</tt>
	allows Apache to compute <tt>PATH_INFO</tt> as most software
	expects.</p>
    <p>Here's a description of the configuration directives accepted by
        this Apache module. The information is largely derived from the source,
        so please excuse (or better yet: help improve) poor descriptions:</p>
    <table width="99%" border="0" cellpadding="2" cellspacing="0">
      <col width="43*" />
      <col width="52*" />
      <col width="57*" />
      <col width="103*" />
      <tr>
        <th width="17%" bgcolor="#E6E6E6">
          <p>
            <strong>Directive</strong>
          </p>
        </th>
        <th width="20%" bgcolor="#E6E6E6">
          <p>
            <strong>Arguments</strong>
          </p>
        </th>
        <th width="22%" bgcolor="#E6E6E6">
          <p>
            <strong>Example</strong>
          </p>
        </th>
        <th width="40%" bgcolor="#E6E6E6">
          <p>
            <strong>Description</strong>
          </p>
        </th>
      </tr>
      <tr>
        <td width="17%" bgcolor="#E6E6E6">
          <p>
            <tt>SCGIMount</tt>
          </p>
        </td>
        <td width="20%" bgcolor="#E6E6E6">
          <p><tt>http</tt> path and IP/port pair</p>
        </td>
        <td width="22%" bgcolor="#E6E6E6">
          <p>
            <tt>/dynamic 127.0.0.1:4000</tt>
          </p>
        </td>
        <td width="40%" bgcolor="#E6E6E6">
          <p>Path prefix and address of SCGI server</p>
        </td>
      </tr>
      <tr>
        <td width="17%" bgcolor="#E6E6E6">
          <p>
            <tt>SCGIServer</tt>
          </p>
        </td>
        <td width="20%" bgcolor="#E6E6E6">
          <p>IP address and port</p>
        </td>
        <td width="22%" bgcolor="#E6E6E6">
          <p>
            <tt>127.0.0.1:4000</tt>
          </p>
        </td>
        <td width="40%" bgcolor="#E6E6E6">
          <p>Address and port of an SCGI server</p>
        </td>
      </tr>
      <tr>
        <td width="17%" bgcolor="#E6E6E6">
          <p>
            <tt>SCGIHandler</tt>
          </p>
        </td>
        <td width="20%" bgcolor="#E6E6E6">
          <p><em>On</em> or <em>Off</em></p>
        </td>
        <td width="22%" bgcolor="#E6E6E6">
          <p>
            <tt>On</tt>
          </p>
        </td>
        <td width="40%" bgcolor="#E6E6E6">
          <p>Enable delegation of requests through SCGI</p>
        </td>
      </tr>
      <tr>
        <td width="17%" bgcolor="#E6E6E6">
          <p>
            <tt>SCGIServerTimeout</tt>
          </p>
        </td>
        <td width="20%" bgcolor="#E6E6E6">
          <p>Number of seconds</p>
        </td>
        <td width="22%" bgcolor="#E6E6E6">
          <p>10</p>
        </td>
        <td width="40%" bgcolor="#E6E6E6">
          <p>Timeout for communication with SCGI server</p>
        </td>
      </tr>
    </table>
    <h2>Server process</h2>
    <p>To install the Python module for creating SCGI applications, go to
        the main SCGI source directory and run <tt><em>python setup.py
        build</em></tt> and then, as <tt>root</tt>, <em><tt>python setup.py
        install</tt>.</em> Or, on most GNU/Linux systems, just install the
        <tt>python-scgi</tt> package.</p>
    <p>The hard part is creating that application server process. The SCGI
        home page provides a server implementation in Python, called
        <tt>scgi_server.py</tt>, but this is really just a kind of support
        module. In order to port an application to use this server, write a
        main program in Python that imports this module and uses it. There is
        one, fairly complex, example that makes an application called <a href="http://www.quixote.ca/">Quixote</a> run over
        SCGI.</p>
    <p>The main program that you write for yourself creates a handler class
        describing how requests should be processed. You then tell the SCGI
        server module to loop forever, handling incoming requests and creating
        processes running your handler class as needed. <em>It is your own
        responsibility to ensure that the server process is running.</em></p>
    <p>Once the SCGI server process runs, it can accept requests forwarded
        by the <tt>http</tt> server. It will attempt to delegate every request
        that comes in to an existing child process, invoking its handler. If no
        child process is free to take the request, an additional child process
        is spawned (if the configured maximum number of child processes is not
        exceeded; if it is, the request blocks until a child process becomes
        free). If a handler "dies" (e.g. exits with an exception), a new child
        is spawned to replace it.</p>
    <h3>Writing a handler</h3>
    <p>The server process must <tt>import scgi_server</tt>, then derive
        handler classes from <tt>scgi_server.SCGIHandler</tt>. Just
        <tt>scgi_server.py</tt> can also be run standalone, in which case it
        return pages displaying the details of your browser's request.</p>
    <p>Your handler class should be derived from the <tt>SCGIHandler</tt>
        class defined in <tt>scgi_server.py</tt>, and override its
        <tt>produce()</tt> function to process a request. This is new in SCGI
        1.12. Before that, the function to override was
        <tt>handle_connection()</tt> which involved a lot more work.</p>
    <p>Besides <em><tt>self</tt>,</em> the <tt>produce()</tt> function
        takes several arguments:</p>
    <ol>
      <li>
        <p style="margin-bottom: 0in">
          <em>a dict mapping names of CGI
            parameters to request details</em>
        </p>
      </li>
      <li>
        <p style="margin-bottom: 0in">
          <em>size (in bytes) of the request
            body</em>
        </p>
      </li>
      <li>
        <p style="margin-bottom: 0in">
          <em>an input stream providing the
            request body</em>
        </p>
      </li>
      <li>
        <p>
          <em>an output stream to write a page to.</em>
        </p>
      </li>
    </ol>
    <p>Alternatively, override <tt>SCGIHandler.produce_cgilike()</tt> which
        can read the request body from standard input, write its output to
        standard output, and receives its request details both as an argument
        dict and added to its environment variables.</p>
    <p>Your output should start out with an <tt>http</tt> header, so
        normally you'd want to start out with something like <tt>"Content-Type:
        text/plain\r\n\r\n"</tt> followed by page content.</p>
    <p>Besides a header containing CGI variables, the request may also
        contain a body. The length of this body is passed as the CGI parameter
        <tt>CONTENT_LENGTH</tt>, but for your convenience is also converted to
        an integer and passed separately to the <tt>produce()</tt> function. If
        your handler needs the request body, it can read this number of bytes
        from its input socket. Do not rely on EOF; explicitly read the correct
        number of bytes (or less, if that's what you want).</p>
    <h3>Writing a server</h3>
    <p>Your main SCGI server program should create an <tt>SCGIServer</tt>
        object (defined in <tt>scgi_server.py</tt>), passing in your handler
        class for the <tt>handler_class</tt> parameter, and then call its
        <tt>serve()</tt> method which will loop indefinitely to process
        requests:</p>
    <pre>
def main():
    SCGIServer(handler_class=MyAppHandler).serve()

if __name__ == "__main__":
    main()
</pre>
    <p>You may want to support command-line options to influence various
        options of the server's operation. The <tt>SCGIServer</tt>
        initialization function takes several arguments:</p>
    <center>
      <table width="67%" border="0" cellpadding="2" cellspacing="0">
        <col width="53*" />
        <col width="157*" />
        <col width="46*" />
        <tr>
          <th width="21%" bgcolor="#E6E6E6">
            <p>
              <strong>Name</strong>
            </p>
          </th>
          <th width="61%" bgcolor="#E6E6E6">
            <p>
              <strong>Meaning</strong>
            </p>
          </th>
          <th width="18%" bgcolor="#E6E6E6">
            <p>
              <strong>Default</strong>
            </p>
          </th>
        </tr>
        <tr>
          <td width="21%" bgcolor="#E6E6E6">
            <p>
              <tt>handler_class</tt>
            </p>
          </td>
          <td width="61%" bgcolor="#E6E6E6">
            <p>Class (not object!) of handler to invoke for requests</p>
          </td>
          <td width="18%" bgcolor="#E6E6E6">
            <p>
              <tt>SCGIHandler</tt>
            </p>
          </td>
        </tr>
        <tr>
          <td width="21%" bgcolor="#E6E6E6">
            <p>
              <tt>host</tt>
            </p>
          </td>
          <td width="61%" bgcolor="#E6E6E6">
            <p>Local IP address to bind to</p>
          </td>
          <td width="18%" bgcolor="#E6E6E6">
            <p>
              <em>empty string</em>
            </p>
          </td>
        </tr>
        <tr>
          <td width="21%" bgcolor="#E6E6E6">
            <p>
              <tt>port</tt>
            </p>
          </td>
          <td width="61%" bgcolor="#E6E6E6">
            <p>TCP port to listen on</p>
          </td>
          <td width="18%" bgcolor="#E6E6E6">
            <p>4000</p>
          </td>
        </tr>
        <tr>
          <td width="21%" bgcolor="#E6E6E6">
            <p>
              <tt>max_children</tt>
            </p>
          </td>
          <td width="61%" bgcolor="#E6E6E6">
            <p>Maximum number of child processes to spawn</p>
          </td>
          <td width="18%" bgcolor="#E6E6E6">
            <p>5</p>
          </td>
        </tr>
      </table>
    </center>
    <h2>Links</h2>
    <ul>
      <li>
        <p style="margin-bottom: 0in">
          <a href="http://python.ca/nas/scgi/">SCGI home
            page</a>
        </p>
      </li>
      <li>
        <p style="margin-bottom: 0in">
          <a href="http://quixote.python.ca/releases/">SCGI download</a>
        </p>
      </li>
      <li>
        <p style="margin-bottom: 0in">
          <a href="http://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/DjangoScgi">
            Setting up Django with SCGI</a>
        </p>
      </li>
      <li>
        <p style="margin-bottom: 0in">
          <a href="http://www.rexx.com/%7Edkuhlman/quixote_scgi.html">Setting up
            Quixote with SCGI</a>
        </p>
      </li>
      <li>
        <p style="margin-bottom: 0in">
          <a href="http://www.zedshaw.com/projects/scgi_rails/">Using Ruby on Rails
            with SCGI</a>
        </p>
      </li>
      <li>
        <p>bazaar-ng (<em>bzr</em>) repository: <a href="http://quixote.python.ca/scgi.dev/">http://quixote.python.ca/scgi.dev/</a></p>
      </li>
    </ul>
  </body>
</html>