15 November 2004
This post may be outdated due to it was written on 2004. The links may be broken. The code may be not working anymore. Leave comments if needed.

Intro

此文并非介绍FastCGI的好处,只是简单的介绍我的一次安装过程。
我的Env为 Win2000+SP4, Apache/2.0.50 (Win32) mod_perl/1.99_15-dev Perl/v5.8.4 mod_ssl/2.0.50 OpenSSL/0.9.7d PHP/4.3.7
$Apache_dir = "C:/Apache2"; $Perl_dir = "C:/usr";

Step by step

  1. http://www.fastcgi.com/dist/ 下载mod_fastcgi-2.4.2-AP20.dll(如果是Apache版本为1.3,下载mod_fastcgi-2.4.2-AP13.dll)。
  2. 遵从http://www.fastcgi.com/mod_fastcgi/INSTALL最下面的一段话:
    To install mod_fastcgi (built above or retrieved from 
    http://fastcgi.com/dist/):
    
      1. Copy the mod_fastcgi.dll to the Apache modules directory 
         (e.g. C:\Apache\modules)
    
      2. Edit the httpd configurion file (e.g. C:\Apache\conf\httpd.conf)
         and add a line like:
    
         LoadModule fastcgi_module modules/mod_fastcgi.dll
    
         Note that if there's a ClearModuleList directive after new entry,
         you'll have to either move the LoadModule after the ClearModuleList
         or add (have a look at how the other modules are handled):
    
         AddModule mod_fastcgi.c
    
      3. Edit the httpd configuration file(s) to enable your FastCGI
         application(s).  See docs/mod_fastcgi.html for details.
    
    简单翻译为
      1. 拷贝 mod_fastcgi.dll(我们下来的mod_fastcgi-2.4.2-AP*.dll,将其改名) 至Apache modules(模块)目录
         (如 C:\Apache\modules)
    
      2. 编辑httpd配置文件 (如 C:\Apache\conf\httpd.conf)
         然后增加如下一行:
    
         LoadModule fastcgi_module modules/mod_fastcgi.dll
    
         注意如果在此句以后出现 ClearModuleList 指示/directive,你必须要么移动LoadModule到ClearModuleList下面或增加(参考其他handled模块):
    
         AddModule mod_fastcgi.c
    
      3. 编辑httpd配置文件去启动你的FastCGI程序。更详细的请参考 docs/mod_fastcgi.html
    
  3. visit http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html, 参考此文档在httpd.conf里增加:
    
    <Directory "E:/Fayland/fcgi-bin">
    	SetHandler fastcgi-script
    	AddHandler fastcgi-script fcg fcgi fpl
    	Options +ExecCGI
    </Directory>
    
  4. 不要下载FCGI.pm-0.64-win32-x86.zip,可以cpan或ppm FCGI安装FCGI.pm和相关文件。
  5. 测试代码:(E:\Fayland\fcgi-bin\test.fpl)
    #!/usr/bin/perl
    use FCGI;
    use strict;
    
    my $count = 0;
    my $request = FCGI::Request();
    
    while($request->Accept() >= 0) {
    	$count++;
    	print "Content-type:text/html\n\n";
    	print "total request $count";
    }
    
    visit: http://localhost/fcgi-bin/test.fpl.

Refer



blog comments powered by Disqus