?? ch11_01.htm
字號:
<html><head><title>Web Server Programming with mod_perl (Perl in a Nutshell, 2nd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Stephen Spainhour" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly & Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596002416L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Perl in a Nutshell, 2nd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Java and XSLT" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch10_07.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch11_02.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h1 class="chapter">Chapter 11. Web Server Programming with mod_perl</h1><div class="htmltoc"><h4 class="tochead">Contents:</h4> <p> <a href="#perlnut2-CHP-11-SECT-1">Design of mod_perl</a><br /><a href="ch11_02.htm">Installing mod_perl</a><br /><a href="ch11_03.htm">mod_perl Handlers</a><br /><a href="ch11_04.htm">Running CGI Scripts with mod_perl</a><br /><a href="ch11_05.htm">Server-Side Includes with mod_perl</a><br /><a href="ch11_06.htm"><Perl> Sections</a><br /><a href="ch11_07.htm">Apache:: Modules</a><br /></p></div><p>A common criticism of CGI is that it requires forking extra processeseach time a script is executed. If you have only a few hits an hour,or even a few hits a minute, this isn't a big deal.But for a high-traffic site, lots of repeatedly spawning CGI scriptscan have an unfortunate effect on the machine running the web server.The CGI scripts will be slow, the web server will be slow, and otherprocesses on the machine will slow to a crawl.</p><p><a name="INDEX-1715" /></a><a name="INDEX-1716" /></a><a name="INDEX-1717" /></a>The solution to this problem is<em class="emphasis">mod_perl</em>. <em class="emphasis">mod_perl</em>, writtenby Doug MacEachern and distributed under CPAN, embeds the Perlinterpreter directly into the web server. The effect is that your CGIscripts are precompiled by the server and executed without forking,thus running much more quickly and efficiently. Furthermore, CGIefficiency is only one facet of <em class="emphasis">mod_perl</em>. Since<em class="emphasis">mod_perl</em> is a complete Apache/Perl hybrid, otherbenefits to <em class="emphasis">mod_perl</em> include:</p><ul><li><p>Writing server-side includes in Perl</p></li><li><p>Embedding Perl code into the Apache configuration files</p></li><li><p>Writing complete Apache modules in Perl</p></li></ul><div class="sect1"><a name="perlnut2-CHP-11-SECT-1" /></a><h2 class="sect1">11.1. Design of mod_perl</h2><p><em class="emphasis">mod_perl</em> is a Perl runtime library linked intothe Apache server. With <em class="emphasis">mod_perl</em>, the Perlprogrammer has access to Apache's C language APIthrough an object-oriented Perl interface. This means that you canwrite Apache modules and extensions entirely in Perl and embed Perlcode and custom directives in your Apache configuration files.Furthermore, the embedded Perl interpreter removes the overhead thatyou'd experience if you'd merelywritten a Perl CGI program and put it in Apache's<em class="filename">cgi-bin</em>.</p><p>Aside from the framework mentioned above, another major benefit of<em class="emphasis">mod_perl</em> is the Apache::Registry module.Apache::Registry implements the CGI environment under the<em class="emphasis">mod_perl</em> framework, which means that you canreuse most of your existing Perl CGI programs to realize the benefitsof <em class="emphasis">mod_perl</em>. Apache::Registry caches compiledscripts on the first execution of a script and updates scripts thathave changed on disk.</p><p>Finally, <em class="emphasis">mod_perl</em> gives the Perl programmer theability to interact with all stages of an HTTP request, many of whicharen't available through CGI. These include theApache handler phase, the HTTP header parser, URI translation,authentication, authorization, access (permissions), type checking,fixup, and logger stages.</p><p>Now that you've been subjected to two ratheroptimistic paragraphs, we'll take a few moments toappease the cynics. It might occur to you that sticking a largeprogram into another large program makes a very, very large program.<em class="emphasis">mod_perl</em> certainly makes<em class="emphasis">httpd</em> significantly bigger. If you have limitedmemory capacity, <em class="emphasis">mod_perl</em> may not be for you.There are several ways to minimize the size of Apache with<em class="emphasis">mod_perl</em> (which you can find in the<em class="emphasis">mod_perl</em> manpage or the FAQs), ranging fromfiddling with Apache configuration directives to building Perl withreduced memory consumption.</p></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch10_07.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch11_02.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">10.7. CGI.pm Reference</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">11.2. Installing mod_perl</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2002</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"> </map></body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -