如何使用 IIS 7.5 配置 Perl/FCGI (FastCGI)?

发布于 2024-11-08 22:51:39 字数 2193 浏览 6 评论 0原文

我正在尝试让 Perl/FastCGI (FCGI) 与 IIS 7.5 一起运行。 C:\Windows\System32\inetsrv\iisfcgi.dll 的版本为 7.5.7601.17514。这是我的 web.config 和 Perl 脚本:

D:\MiLu\Dev :: more /t1 web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <directoryBrowse enabled="true" />
  <handlers>
   <add name="FCGI" path="*.pl" verb="*"
    modules="FastCgiModule"
    scriptProcessor="C:\Opt\Cygwin\bin\perl.exe"
    resourceType="Unspecified" requireAccess="Script" />
  </handlers>
 </system.webServer>
</configuration>

D:\MiLu\Dev :: more /t4 Perl\fcgi\count.pl
use strict;
use warnings;
use FCGI;

my $count = 0;
my $request = FCGI::Request();

while ( $request->Accept >= 0 ) {
    print "Content-type: text/html\r\n\r\n", ++$count;
}

我得到的只是 500,其中包含来自 IIS 的通用错误页面,指出“FastCGI 进程意外退出”并列出了可能的错误原因。

该脚本从命令行运行良好,打印了三行然后立即退出,表明脚本和模块安装正常。 (顺便说一下,我是从FCGI手册复制的,所以应该没问题。)

D:\MiLu\Dev :: C:\Opt\Cygwin\bin\perl.exe Perl\fcgi\count.pl
Content-type: text/html

1

有一个FCGI::IIS 模块,但是,它似乎仅适用于 IIS 5.1 和 6.0。

事实上,IIS 有一个专用的 FCGI 模块,这表明 IIS 5.1 和 6.0 提供了自己的非标准 FCGI 实现。那么如果这是真的,那么 IIS 7.5 又如何呢?相当多的不确定性。

FCGI::IIS 的作者似乎尝试让他的模块与 IIS 7.0 一起工作(获取Perl 在 IIS7 上使用 FastCGI - 2007),但放弃了。

我在哪里可以找到更具体的错误信息?有日志文件吗?我应该在 Windows 事件查看器 (eventvwr) 中查找什么?

是否有一些我缺少的 IIS 魔法咒语?

关于这种组合的信息并不多。但最终它可能会起作用。这里有一个FastCGI应用程序配置参考页面,以及有人让 Catalyst 在 IIS 7.0 上与 FastCGI 配合使用(在 MS Windows 2008/Vista 上为 Catalyst+IIS 7.0)

I'm trying to get Perl/FastCGI (FCGI) running with IIS 7.5. The version of C:\Windows\System32\inetsrv\iisfcgi.dll is 7.5.7601.17514. Here's my web.config and my Perl script:

D:\MiLu\Dev :: more /t1 web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <directoryBrowse enabled="true" />
  <handlers>
   <add name="FCGI" path="*.pl" verb="*"
    modules="FastCgiModule"
    scriptProcessor="C:\Opt\Cygwin\bin\perl.exe"
    resourceType="Unspecified" requireAccess="Script" />
  </handlers>
 </system.webServer>
</configuration>

D:\MiLu\Dev :: more /t4 Perl\fcgi\count.pl
use strict;
use warnings;
use FCGI;

my $count = 0;
my $request = FCGI::Request();

while ( $request->Accept >= 0 ) {
    print "Content-type: text/html\r\n\r\n", ++$count;
}

All I'm getting is a 500 with a generic error page from IIS stating "The FastCGI process exited unexpectedly" and listing possible error causes.

The script runs fine from the command line, printing its three lines and then exiting immediately, indicating that script and module installation are alright. (I copied it from the FCGI manual, by the way, so it should be okay.)

D:\MiLu\Dev :: C:\Opt\Cygwin\bin\perl.exe Perl\fcgi\count.pl
Content-type: text/html

1

There is an FCGI::IIS module, however, it appears to have worked only for IIS 5.1 and 6.0.

The fact that there is a dedicated FCGI module for IIS suggests that IIS 5.1 and 6.0 provided their own non-standard FCGI implementation. So if this were true, what about IIS 7.5 then? Quite a lot of uncertainties.

The author of FCGI::IIS seems to have tried to make his module work with IIS 7.0 (Getting Perl working on IIS7 with FastCGI - 2007), but given up.

Where can I find something more concrete as to what the error is? Is there a log file? What should I be looking for in the Windows event viewer (eventvwr)?

Is there some magic incantation for IIS that I'm missing?

There's not much information out there on this combination. But it might work, in the end. There is a FastCGI Application configuration reference page here, and someone has got Catalyst to work with FastCGI on IIS 7.0 (Catalyst+IIS 7.0 on MS Windows 2008/Vista).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

偏闹i 2024-11-15 22:51:39

我已经有一段时间没有这样做了,而且从来没有使用过 Cygwin。
为了测试这一点,您可以下载并安装适合您的体系结构的最新活动状态 Perl 并尝试按如下方式安装/配置:

http://legacy.websitepanel.net/kb/installing-and-running-active-perl-runtime-as-isapi-on-microsoft-iis-7.0

另一个参考:

http://blogs.iis.net/wadeh/archive/2009/04/13/running-perl-on-iis-7.aspx

祝你好运。

I've not done this for a while, and never with Cygwin.
In order to test this could you please download and install the latest active state perl for your architecture and try installing/configuring as below:

http://legacy.websitepanel.net/kb/installing-and-running-active-perl-runtime-as-isapi-on-microsoft-iis-7.0

Another reference:

http://blogs.iis.net/wadeh/archive/2009/04/13/running-perl-on-iis-7.aspx

Good luck.

醉城メ夜风 2024-11-15 22:51:39

 我刚刚遇到过这个。您引用的许多链接都是我的。在我撰写这些指南时,FastCGI for IIS 是全新的,Vista 版本尚未推出。不幸的是,由于工作原因,我最终参与了其他项目,并且在 Vista (IIS 7) 版本发布后没有机会继续使用这些指南。

我刚刚接触到一个再次需要此指南的项目,并且在我自己寻找解决方案时,我看到了您的帖子。我做了一些测试并设法找到了解决方案。

FastCGI 在 Windows 上的工作方式与在 Linux 上的工作方式根本不同。不仅是 IIS 版本,Apache 版本也是如此。

在 Linux 上,您可以将 FastCGI 设置为处理程序,脚本的 shebang 将足以将其指向 Perl 并执行正确的操作(只要您为 FCGI 或 CGI::Fast 编写了脚本)。

在 Windows 上,您需要指定要使用处理程序调用的 FastCGI 脚本:

IIS 7
IIS管理器->站点->网站->处理程序映射 ->添加模块映射...
请求路径:test_script.fcgi
模块:FastCgiModule
可执行文件:c:\perl\bin\perl.exe|c:\inetpub\wwwroot\test_script.fcgi
名称:测试FCGI示例
单击确定,然后选择添加 FastCGI 应用程序。如果您检查服务器的 FastCGI 设置,您将需要 | 之后的部分。设置为可执行文件 (Perl) 的参数。
重新启动服务器(不仅仅是网站)。它应该可以工作。不幸的是,如果您想使用此技术,您需要为每个脚本添加一个映射。 FCGI::IIS 模块试图解决这个问题,但它有很多警告并且尚未完成。

阿帕奇
我通过将 mod_fcgid.so 文件复制到适当的目录并更新 httpd.conf 在 WAMP 上对此进行了测试:


;
FcgidInitialEnv 路径“C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/Perl/bin”
FcgidInitialEnv 系统根目录“C:/Windows”
FcgidInitialEnv 系统驱动器“C:”
FcgidInitialEnv TEMP "C:/WINDOWS/Temp"
FcgidInitialEnv TMP“C:/WINDOWS/Temp”
FcgidInitialEnv Windir "C:/WINDOWS"
FcgidIO 超时 64
Fcgid连接超时 16
FcgidMaxRequestsPerProcess 1000
Fcgid最大进程数 1
FcgidMaxRequestLen 8131072
<文件〜“\test_script.fcgi$”>
期权索引 FollowSymLinks ExecCGI
AddHandler fcgid-脚本 .fcgi
FcgidWrapper“C:/Perl/bin/perl.exe c:/wamp/www/test_script.fcgi”.fcgi


我希望这可以帮助任何面临与您相同问题的人。

莱尔

  I've just come across this. A lot of the links you reference are mine. At the time I was writing those guide FastCGI for IIS was brand new, and the Vista version wasn't out yet. Unfortunately due to work I ended up on other projects and didn't get chance to continue with the guides once the Vista (IIS 7) version came out.

I've only just come to a project that needs this again, and in searching for a solution myself I came across your post. I've done some testing and managed to find a solution.

FastCGI works fundamentally differently on Windows to what it does on Linux. It's not just with the IIS version, but with the Apache version as well.

On Linux you can set FastCGI as the handler, and the shebang for the script will be enough to point it to Perl and do the right thing (as long as you've coded your script for FCGI or CGI::Fast).

On Windows you need to specify the FastCGI script you want to be invoked with the handler:

IIS 7:
IIS Manager -> Sites -> Web site -> Handler Mappings -> Add Module Mapping...
Request Path: test_script.fcgi
Module: FastCgiModule
Executable: c:\perl\bin\perl.exe|c:\inetpub\wwwroot\test_script.fcgi
Name: Test FCGI example
Click OK then select to add the FastCGI application. If you check the FastCGI settings for the server you'll need that the part after the | is set as the arguments to the executable (Perl).
Restart the server (not just the website). It should be working. Unfortunately, if you want to use this technique you'll need to add a mapping for each script. The FCGI::IIS module tried to work around this issue, but it has a lot of Caveats and isn't finished.

Apache
I tested this on WAMP by copying the mod_fcgid.so file to the appropriate directory, and updating httpd.conf:


<IfModule fcgid_module>
FcgidInitialEnv PATH "C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/Perl/bin"
FcgidInitialEnv SystemRoot "C:/Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "C:/WINDOWS/Temp"
FcgidInitialEnv TMP "C:/WINDOWS/Temp"
FcgidInitialEnv windir "C:/WINDOWS"
FcgidIOTimeout 64
FcgidConnectTimeout 16
FcgidMaxRequestsPerProcess 1000
FcgidMaxProcesses 1
FcgidMaxRequestLen 8131072
<Files ~ "\test_script.fcgi$">
Options Indexes FollowSymLinks ExecCGI
AddHandler fcgid-script .fcgi
FcgidWrapper "C:/Perl/bin/perl.exe c:/wamp/www/test_script.fcgi" .fcgi
</Files>
</IfModule>

I hope that helps anyone facing the same issues as you.

Lyle

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文