<ol start=“2”>
<li><blockquote>
<p>The event Multi-Processing Module (MPM) is designed to allow more
requests to be served simultaneously by passing off some processing
work to supporting threads, freeing up the main threads to work on new
requests.
<a href="http://httpd.apache.org/docs/2.2/mod/event.html" rel="nofollow">http://httpd.apache.org/docs/2.2/mod/event.html</a></p>
</blockquote></li>
<li><blockquote>
<p>This Multi-Processing Module (MPM) implements a non-threaded,
pre-forking web server. Each server process may answer incoming
requests, and a parent process manages the size of the server pool. It
is appropriate for sites that need to avoid threading for
compatibility with non-thread-safe libraries. It is also the best MPM
for isolating each request, so that a problem with a single request
will not affect any other.
<a href="http://httpd.apache.org/docs/current/mod/prefork.html" rel="nofollow">http://httpd.apache.org/docs/current/mod/prefork.html</a></p>
</blockquote></li>
</ol>
<p>(五)</p>
<blockquote>
<p>a2enmod is a script that enables the specified module within
the apache2 configuration.
<a href="http://manpages.ubuntu.com/manpages/lucid/man8/a2enmod.8.html" rel="nofollow">http://manpages.ubuntu.com/manpages/lucid/man8/a2enmod.8.html</a></p>
</blockquote>
<p>名称<code>a2enmod</code>代表<em>apache2 enable module</em>。在</p>
<blockquote>
<p>For some reason the first two lines of the script.py are absolutely
necessary.</p>
</blockquote>
<p>第一个命令告诉apache如何执行cgi脚本。毕竟,还有其他服务器端语言,比如php、perl、ruby等,apache如何知道您使用的是哪种服务器端语言?在</p>
<p>第二行输出一个HTTP头,这是您可以使用的最简单的头。协议体的头必须是http的输出方式。在</p>
<blockquote>
<pre><code>sudo chmod +x /usr/lib/cgi-bin/script.py
</code></pre>
<p>why do I need this? how come it is not executable by default?</p>
</blockquote>
<p>除非管理员授予执行文件的权限,否则无法执行该文件。这是出于安全原因。在</p>
<blockquote>
<p>If there is a more obvious/better/correct way to run a python script
using Apache24, I would really love to learn it.</p>
</blockquote>
<p>您列出的大多数命令都是用来设置apache配置的。您不应该每次执行cgi脚本时都运行这些命令。一旦配置了apache,您所要做的就是启动apache,然后请求一个web页面。在</p>
<blockquote>
<p>P.S. Some people recommend adding:</p>
<pre><code>AddHandler cgi-script .py .cgi
</code></pre>
<p>to /etc/apache2/conf-enabled/serve-cgi-bin.conf if you encounter a
problem when running a script on Apache. But for some reason it
doesn't make any difference in my case. Why?</p>
</blockquote>
<p>请看这里:</p>
<blockquote>
<p>AddHandler handler-name extension [extension]</p>
<p>Files having the name extension will be served by the specified
handler-name. This mapping is added to any already in force,
overriding any mappings that already exist for the same extension. For
example, to activate CGI scripts with the file extension .cgi, you
might use:</p>
<p>AddHandler cgi-script .cgi</p>
<p>Once that has been put into your httpd.conf file, any file containing
the .cgi extension will be treated as a CGI program.
<a href="http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addhandler" rel="nofollow">http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addhandler</a></p>
</blockquote>
<p>因此,当您添加AddHandler行时,它似乎正在重写某个执行相同操作的配置设置。在</p>
<p><strong>回复评论</strong>:</p>
<blockquote>
<p>ScriptInterpreterSource Directive</p>
<p>This directive is used to control how Apache httpd finds the
interpreter used to run CGI scripts. The default setting is Script.
This causes Apache httpd to use the interpreter pointed to by the
shebang line (first line, starting with #!) in the script
<a href="http://httpd.apache.org/docs/current/mod/core.html" rel="nofollow">http://httpd.apache.org/docs/current/mod/core.html</a></p>
</blockquote>
<p>在同一页上,有这样的指示:</p>
<blockquote>
<p>CGIMapExtension Directive</p>
<p>This directive is used to control how Apache httpd finds the
interpreter used to run CGI scripts. For example, setting
CGIMapExtension sys:\foo.nlm .foo will cause all CGI script files with
a .foo extension to be passed to the FOO interpreter.</p>
</blockquote>