Perl, IIS and FastCGI



I have a FastCGI Perl application that runs well with the Apache and
the FastCGI module on Windows and Linux. Recently though, I needed to
get it running with IIS (version 6) and so I turned to the FastCGI
ISAPI DLL written by Shane Caraveo and now part of the PHP source tree
( I had some
difficulties getting my app working like it does with the Apache
FastCGI module and so I though I'd share my experiences.

So my goal was to get the ISAPI DLL to create CGI servers dynamically
based on the requested URL as can be done with the Apache module. In
the end this required a code change to the ISAPI DLL. The patches are
below. (I should submit these to the PHP project.) Basically I had two
problems: preserving Perl's arguments when running dynamic servers and
getting the ISAPI DLL to run the dynamic server as a FastCGI responder
instead of a filter. The changes I made allowed/fixed these.

I then created the following keys in the registry:


In this key, I added the following values:

AppPath REG_SZ c:\tools\perl\5.6.1\bin\MSWin32-x86\perl.exe
Args REG_SZ -T
BindPath REG_SZ

Note that the value of Args is "-T " (with a space). BindPath is empty.
(Perhaps it's not necessary.)
From that point, configuration was just as it is with PHP except that
for the website I associated the DLL with the extension .pl instead of
..php. See instructions here for example:

Other obstacles I encountered not specific to FastCGI and Perl were
ensuring that the account used to run the CGI scripts had all the
proper permissions and that all the dependent DLLs for the FastCGI
ISAPI DLL were on the machine. Here's a useful tool to help with that:

Anyway, I hope this helps save someone else some time.


--- FCGIProcMgr.cpp Thu Apr 27 14:46:38 2006
+++ Thu Apr 27 14:45:54 2006
@@ -388,7 +388,10 @@
proc->incServers = parent->incServers;
proc->maxServers = parent->maxServers;
proc->timeout = parent->timeout;
- if (path) strncpy(proc->args, path, sizeof(proc->args)-1);
+ proc->isFilter = parent->isFilter;
+ *( proc->args ) = 0;
+ if (parent->args) strncpy(proc->args, parent->args,
+ if (path) strncpy(proc->args + strlen (proc->args), path,
sizeof(proc->args)-1 - strlen (proc->args) );
strncpy(proc->bindPath, bindpath, sizeof(proc->bindPath)-1);
if (dwServerImpersonate) {

And I also needed this change to compile it on my machine:

--- fcgi_server.h Thu Apr 27 14:46:38 2006
+++ Thu Apr 27 14:43:46 2006
@@ -25,6 +25,10 @@
#define FCGI_SERVER_VERSION "2.2.2 0.5.2 beta"

extern void InitiateServers(char *szExtension);
extern void CheckServers(char *szExtension);


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question