⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1250.html

📁 著名的linux英雄站点的文档打包
💻 HTML
📖 第 1 页 / 共 3 页
字号:
hello_world模块,现在,重新启动网络服务器,发出请求: http://localhost/hello.<br>
<br>
你将在你的浏览器中看到"Hello World!" 。<br>
<br>
选择合适的模块<br>
<br>
我们现在遇到的最大问题是:在构造模块时,只用到C语言编写的模块, 为了让这<br>
些程序能够在特定的服务器上运行,这些源程序在编译时还必须带上正确的编译开关。<br>
在每次安装Apache时,都必须重新编译这些源程序。要了解使用哪些编译开关的问题,<br>
可以通过运行Apache附带的apxs脚本来获得,但是每次在新的服务器上运行时,都得重<br>
新编译该模块,重新编译始终是个问题。<br>
<br>
有个模块可以解决这些问题,而且该模块还带有更多其他的功能,这就是mod_perl模块,<br>
其功能很强大,本文只能为大家作一些该模块的简单介绍。<br>
<br>
为什么使用mod_perl?<br>
<br>
mod_perl 模块的提供的一个特色是:可以用Perl语言来编写Apache 模块,Perl 是<br>
解释性语言,其优缺点并存。解释性语言的一个主要优点是:每次安装服务器时,不必重新<br>
编译这个模块。缺点是需要一个解释器来阅读和执行实际的程序,这会降低服务器的运行速度,<br>
通过在启动Apache服务器的同时,启动Perl解释器,这样mod_perl就克服了运行速度减慢的问题。<br>
Perl解释器还可以对服务器上的Perl代码进行预先解释,并可以随时捕捉到它,以便一旦<br>
要用到该段代码时,能够快速执行。<br>
<br>
使用mod_perl<br>
mod_perl可以从mod_perl中下载得到 。对于mod_perl的安装和编译的介绍,超出了本文的篇幅,<br>
在网上和mod_perl模块中就提供了不少技术参考资料。为了向大家演示Perl模块的使用,<br>
我下载并复制了Hello.pm,这是个用Perl语言写的Hello World模块。你可以在Perl 5 Module List中找到更多的Perl模块。<br>
<br>
现在,我们需要设置Apache服务器,以便它可以找到我们希望使用的模块。一开始,<br>
要使用mod_perl,我们需要创建一个名为startup.pl 的文件,该文件将为mod_perl所使用,<br>
将会告诉mod_perl所有已安装程序的位置。我们将创建一个最小的startup.pl 文件,可以<br>
用它来访问要运行的Hello World模块,要使得其他模块来说,也能够正常工作,就需要<br>
修改startup.pl 文件。在你的startup.pl 文件中,应包含如下内容:<br>
<br>
# Always a good thing to put at the top of every mod_perl script. This will<br>
# save many headaches as you work.<br>
use strict;<br>
<br>
# Tell mod_perl where to find Hello.pm module<br>
use lib qw(path/to/module)<br>
<br>
# The name of the module to load using mod_perl<br>
use Apache::Hello;<br>
<br>
# This script must return TRUE, and this line accomplishes that, and conveniently<br>
# also checks to ensure that we are actually running mod_perl with our version<br>
# of Apache.<br>
<br>
$ENV{MOD_PERL} or die "not running under mod_perl!";<br>
<br>
<br>
下一步,要使得Hello World模块可以运行,就要对Apache服务器进行配置,以便<br>
使用 mod_perl。在前面的例子中,我们使用了http://localhost/hello作为<br>
访问用C语言编写的模块的请求。 对于Perl模块,我们使用hello_perl。要设置得正确,<br>
就需要编辑httpd.conf 文件。在AddModule行后面的某处添加如下内容:<br>
<br>
<br>
<br>
<br>
<br>
PerlRequire /path/to/startup.pl.<br>
<br>
&lt;Location /hello_perl&gt;.<br>
SetHandler perl-script.<br>
PerlHandler Apache::Hello.<br>
&lt;/Location&gt; .<br>
<br>
PerlRequire行告诉mod_perl到何处去寻找我们先前已经创建的startup.pl文件。<br>
标记为Location 的一节将告诉Apache服务器,对/hello_perl的请求应该用一个特殊<br>
的方式进行处理。在该节里,存在两个指示语:SetHandler和PerlHandler。<br>
SetHandler指示语将告诉Apache,把所有的访问请求发送到mod_perl,之后PerlHandler<br>
就指示mod_perl应该把这些请求转发到Hello World的Perl模块。<br>
<br>
仅剩下最后一个步骤了:把Hello.pm文件复制到适当的位置。一旦创建了startup.pl文件,<br>
我们就规定好了Hello.pm模块的位置。我们需要在那个位置创建一个目录,把Hello.pm文件<br>
复制到该Apache目录中,所以,如果要在startup.pl 文件中把path/to/module设置<br>
为/usr/local/apache/perl/modules,就可以执行如下命令:<br>
<br>
mkdir /usr/local/apache/perl/modules/Apache<br>
cp Hello.pm<br>
/usr/local/apache/perl/modules/Apache<br>
<br>
这就把Hello World模块放到Apache名称空间中,确保没有其他的Perl脚本同它冲突。<br>
此时, Apache和mod_perl都已经设置好,可以运行Hello World了。我们可以重启动服务器。<br>
一旦服务器重启动之后,在你的浏览器位置栏打入 http://localhost/hello_perl,你可以看到如下信息:<br>
<br>
Hello, I see you see me with Lynx/2.8.3dev.8 libwww-FM/2.14<br>
<br>
本文介绍了如何添加外部模块到现有的Apache服务器中, 在网上,除了用C语言<br>
和Perl语言编写的模块之外,也有一些用 Python 语言写的模块可供你下载,并配置到Apache服务器中,<br>
本文也介绍如何自己编写模块,并配置到Apache服务器中的资料。
</FONT><br>
                                      </TD>
                                    </TR>
                                <TR>
                                <TD colSpan=2><FONT 
                                class=middlefont></FONT><BR>
                                        <FONT 
                                class=normalfont>全文结束</FONT> </TD>
                                    </TR>
                                <TR>
                                <TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2 
                                height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
                        <TD vAlign=top width="20%" 
                      background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2> 
                          <DIV align=center> 
                            <table class=tableoutline cellspacing=1 cellpadding=4 
                        width="100%" align=center border=0>
                              <tr class=firstalt> 
                                <td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
                                <font class=normalfont><b>所有分类</b></font></td>
                              </tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td>    </tr>  </table></td></tr>                            </table>
                          </DIV></TD></TR>
                    <TR vAlign=top>
                        <TD width="80%"> 
                          <DIV align=center><BR>
                          </DIV>
                        </TD></TR></TBODY></TABLE></TD></TR>
                </TABLE></TD></TR>
          </TABLE>
      <TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee 
        border=0><TBODY>
        <TR>
          <TD width="50%">
              <P><FONT class=middlefont>版权所有 &copy; 2004 <A 
            href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
                违者必究. </FONT></P>
            </TD>
          <TD width="50%">
              <DIV align=right><FONT class=middlefont>Powered by: <A 
            href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
            </TD></TR></TBODY></TABLE>
      <CENTER></CENTER></TD></TR>
    </TABLE></CENTER></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -