📄 174.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Robots" content="INDEX,NOFOLLOW">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<TITLE>Safari | Python Developer's Handbook -> Configuring Web Servers for Python/CGI Scripts</TITLE>
<LINK REL="stylesheet" HREF="oreillyi/oreillyN.css">
</HEAD>
<BODY bgcolor="white" text="black" link="#990000" vlink="#990000" alink="#990000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellpadding=5 cellspacing=0 border=0 class="navtopbg"><tr><td><font size="1"><p class="navtitle"><a href="8.html" class="navtitle">Web Development</a> > <a href="0672319942.html" class="navtitle">Python Developer's Handbook</a> > <a href="171.html" class="navtitle">11. Web Development</a> > <span class="nonavtitle">Configuring Web Servers for Python/CGI Scripts</span></p></font></td><td align="right" valign="top" nowrap><font size="1"><a href="main.asp?list" class="safnavoff">See All Titles</a></font></td></tr></table>
<TABLE width=100% bgcolor=white border=0 cellspacing=0 cellpadding=5><TR><TD>
<TABLE border=0 width="100%" cellspacing=0 cellpadding=0><TR><td align=left width="15%" class="headingsubbarbg"><a href="173.html" title="Web Development"><font size="1">< BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0672319942&snode=174" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="174.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="175.html" title="Third-Party Internet Applications"><font size="1">CONTINUE ></font></a></td></TR></TABLE>
<a href="5%2F31%2F2002+4%3A43%3A25+PM.html" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><font color=white size=1>152015024128143245168232148039199167010047123209178152124239215162148047091217051046165216</font><a href="read0.asp?bookname=0672319942&snode=174&now=5%2F31%2F2002+4%3A43%3A25+PM" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><br>
<FONT>
<h3>Configuring Web Servers for Python/CGI Scripts</h3>
<p>The next topics show you how to configure the most used Web servers in the market. Mostly you will see how to handle Python CGI scripts within Apache and Microsoft IIS Web servers.</p>
<H4>Python in Apache</H4>
<P>First, let's see how Apache handles requests.</P>
<p>When a file is called, Apache executes an action, which internally is known as <a naME="idx1073746154"></A><I>handler.</i> These handlers are usually implicitly related to the files, based on the file type. However, new Apache releases are able to assign handles to filename extensions or file locations, instead of only work with the file type.<a naME="idx1073746155"></A><A name="idx1073746156"></a><a name="idx1073746157"></a><a name="idx1073746158"></a><a naMe="idx1073746159"></a><A namE="idx1073746160"></a><a naMe="idx1073746161"></a><a NAME="idx1073746162"></a><a naME="idx1073746163"></A><A name="idx1073746164"></A><A NAme="idx1073746165"></a></p>
<P>Python script files are handled in exactly the same way as other CGI scripts. Once a request is received, Apache calls the Python interpreter asking it to run the specific script. Depending on the Apache configuration, there are several actions to be performed when receiving a request (for instance, user authentication and file transfer).</P>
<P>Apache comes with a predefined set of handlers for basic routine tasks. However, there are several third-party handler applications that can be very useful as well, such as the <Tt class="monofont">mod_python</tt> and <tt class="monofont">mod_pyapache modules.</tt> Using these modules is not strictly necessary, but it reduces the overhead of your server and increases the speed of your application. Both of these reasons occur because the Python interpreter is not called for every single connection anymore. You can create Apache Handlers by building them into the Web Server, adding them to the Action directive, or implementing a module. <a naMe="idx1073746166"></a></P>
<p>The Apache official Web site is as follows:</p>
<p>
<A targEt="_blank" hrEF="http://www.apache.org/">http://www.apache.org/</A></P>
<h5>Configuring Apache for Python</h5>
<p>The following guidelines will help you configure your Apache installation to run Python in both Windows and UNIX systems. Steps 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -