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

📄 asgxc.htm

📁 apache技术手册
💻 HTM
📖 第 1 页 / 共 3 页
字号:

<BR>

<P>The patch process is simple; you just replace a few files in the standard Perl distribution with files provided in the kit. Here's the process:

<BR>

<OL>

<LI>1. Put the unarchived Perl and fcgi-devel-kit on a directory side by side and issue the following commands:

<BR>% cd perl5.002

<BR>% mv perl.c perl.c.dist

<BR>% mv proto.h proto.h.dist

<BR>% mv Configure Configure.dist

<BR>% cp -r ../fcgi-devel-kit/perl-5/perl5.002/*

<BR>% cp -r ../fcgi-devel-kit/perl-5/common/*

<BR>

<LI>2. Set the environment variable FCGIDIR to the absolute path of the fcgi-devel-kit. In my case, the distribution was in the /tmp/fcgiPerl directory. This variable will tell the configuration program where to find things:

<BR>setenv FCGIDIR /tmp/fcgiPerl/fcgi-devel-kit

<BR>

<LI>3. If you don't use gcc, set the environment variable CC to the name of your compiler:

<BR>setenv CC cc

<BR>

<LI>4. If you want to install the Perl distribution somewhere other than /usr/local/bin, define the environment variable PERL_PREFIX. I kept the default setting.

<BR>

<BR>

<LI>5. Execute the fcgi-configure script:

<BR>% ./fcgi-configure

<BR>The fcgi-configure script is a wrapper that automatically sets some of the configure variables without requiring user input. If this fails, you'll have to run the Configure command in the Perl directory. You may want to take a look at the documentation that came with the FastCGI Developer's Kit for any tips to solve the problem.

<BR>

<BR>

<LI>6. Do a make to build the software:

<BR>% make

<BR>

</OL>

<P>If it all goes smoothly, you can finish the installation with a make install, which will install Perl to the location specified. That's it for the install! Make sure your scripts reference the correct version of Perl.

<BR>

<BR>

<A NAME="E69E216"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Perl FastCGI Programs</B></FONT></CENTER></H4>

<BR>

<P>The modified version of my HelloWorld.c looks like this:

<BR>

<PRE>

<FONT COLOR="#000080">#!/usr/local/bin/perl

use strict;

use FCGI;

my($timesVisited) = 0;

while(FCGI::accept() &gt;=0){

 print &quot;Content-type: text/plain\n\n&quot;;

 print &lt;&lt;STOP;

 &lt;HTML&gt;

 &lt;HEAD&gt;

 &lt;TITLE&gt;Hello World!&lt;/TITLE&gt;

 &lt;/HEAD&gt;

 &lt;BODY&gt;

 &lt;H1&gt;Hello, this is a FastCGI program!&lt;/H1&gt;

 &lt;P&gt;I can tell that you are visiting from $ENV{REMOTE_HOST}&lt;/P&gt;

 &lt;P&gt;This page has been accessed: ++$timesVisited&lt;/P&gt;

 &lt;/BODY&gt;

 &lt;/HTML&gt;

 STOP

}</FONT></PRE>

<P>As you can see, this is pretty much the same organization as the C program. The one gotcha with Perl is that if the initial environment to a FastCGI Perl application is empty when the first call to FCGI::accept returns, the environment will still be empty. The easiest workaround is to add an environment with the AppClass -initial-env directive. See the section entitled, &quot;The AppClass Directive,&quot; for more detailed information.

<BR>

<BR>

<A NAME="E68E190"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>The </B><B>mod_fastcgi</B><B> Module</B></FONT></CENTER></H3>

<BR>

<P>The FastCGI module provides Apache compatibility to FastCGI applications. This module is not part of the standard Apache release, so you'll have obtain a copy from http://www.fastcgi.com. A copy of the latest version at the time this was written, August 1996, is included on the CD-ROM.

<BR>

<P>This module processes any file with a MIME-type application/x-httpd-fcgi. Because the ScriptAlias directive may have higher priority over AddType, FastCGI applications should not reside on the cgi-bin directory; if they do, they may be processed by the mod_cgi module regardless of the extension given. This means that the application/x-httpd-fcgi MIME type is given to files that do <I>not</I> reside in the ScriptAlias directory and that have a name using the extension defined by the AddType application/x-httpd-cfgi directive. Typically this will be .fcgi. The reason for this is that Apache assigns priority to the directives based on the order of compilation in the modules.

<BR>

<BR>

<A NAME="E69E217"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>The </B><B>AppClass</B><B> Directive</B></FONT></CENTER></H4>

<BR>



<TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="80%" CELLPADDING=2 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<A NAME="I3"></A>Syntax:

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

AppClass <I>executablePath </I>[-processes <I>p</I>] [-listen-queue-Depth <I>q</I>] [-restart-delay <I>secs</I>] [-priority <I>N</I>] [-initial-env <I>key=value</I>]

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Default:

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

AppClass <I>executablePath </I>[-processes 1] [-listen-queue-Depth 5] [-restart-delay 5] [-priority <I>sameAsHTTP</I>]

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Context:

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

srm.conf

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Module:

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

mod_fastcgi</FONT>

</TABLE><P>The AppClass directive, provided by mod_fastcgi, is responsible for starting up one or more FastCGI application processes using the executable specified by <I>executablePath</I>.

<BR>

<P>When a request for the file specified by executablePath is received, the request is handled by the mod_fastcgi module, which connects the request to the appropriate process belonging to the proper AppClass.

<BR>

<P>In addition to starting the process, the server will ensure that a process for handling a particular AppClass will be available. Should a process exit because of an error or some other condition, the server will launch another process capable of handling the requests.

<BR>

<P>AppClass has several other options:

<BR>



<TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="80%" CELLPADDING=2 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

processes:

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Specifies the number of FastCGI processes that the server will spawn. Default value for this setting is 1.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

listen-queue-depth:

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Sets the depth of the listen queue that is shared by the processes. The <I>listen queue</I> stores additional requests that may be received while the FastCGI application is processing another. Requests will queue until they reach the limit imposed by listen-queue-depth. Additional requests beyond the size of the queue are responded with an error to the client. Default value is 5.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

restart-delay: 

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Specifies the number of seconds the server will wait before restarting a dead FastCGI process. The server won't restart a process more often than the time specified by this flag. The default value is 5 seconds.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

priority: 

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

This flag specifies the execution priority of the FastCGI process. The default priority is inherited from the parent httpd server process.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

initial-env: 

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

This flag allows you to specify the initial environment sent to a FastCGI program when the program initializes. You can specify multiple initial-env flags, one per <I>key=value</I> pair. If not specified, the initial environment is empty. It would be very useful to provide the FastCGI application with information during its initialization phase.</FONT>

</TABLE><BR>

<A NAME="E69E218"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Example</B></FONT></CENTER></H4>

<BR>

<P>If you wanted to start the HelloWorld.fcgi program, you would need to type this:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">AppClass /usr/local/etc/httpd/fcgi-bin/HelloWorld.fcgi -processes 2</FONT></PRE>

<P>For a Perl program, to circumvent the environment problem, you would have to do this:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">AppClass /usr/local/etc/httpd/fcgi-bin/HelloWorld.fcgi -processes 2 -initial- env: DB_PATH_NAME=/proj/accts/db2</FONT></PRE>

<BR>

<A NAME="E68E191"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Summary</B></FONT></CENTER></H3>

<BR>

<P>Although FastCGI is not the sole alternative for high performance CGI alternatives, the features and price cannot be beat. It's especially interesting that existing code can be ported easily without a real learning curve. This alone makes it very attractive for programmers who have a backlog and don't have much time to spend experimenting with new tools, yet need to implement a high-performance CGI solution. FastCGI is a great <A NAME="I4"></A>choice&#151;the learning-and-setup curve is hours, not days like other environments.<A NAME="I5"></A>

<BR>

<P ALIGN=LEFT>

<A HREF="asgxb.htm" tppabs="http://docs.rinet.ru:8080/Apachu/asgxb.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A>

<A HREF="index.htm" tppabs="http://docs.rinet.ru:8080/Apachu/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="asgxd.htm" tppabs="http://docs.rinet.ru:8080/Apachu/asgxd.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>


</BODY></HTML>





⌨️ 快捷键说明

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