Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Perl/FCGI (FastCGI) with IIS 7.5?

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.

  • FastCGI and Perl - FastCGI with Perl on IIS 5.1, 6
  • IIS and FastCGI/Scripting languages/Perl

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).

like image 987
Lumi Avatar asked May 20 '11 21:05

Lumi


2 Answers

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.

like image 83
Raoul Avatar answered Oct 24 '22 13:10

Raoul



  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

like image 2
Cosmicnet Avatar answered Oct 24 '22 13:10

Cosmicnet