FastCGI/IIS for script languages other than PHP - eg. Perl, Python, etc?

"Mike Barborak" <[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <024f01c66d61$0163c990$6401a8c0@Surprise>
Hi,
 
I recently tackled this problem and was able to get it to work after some
code changes.
 
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 (
<http://cvs.php.net/viewcvs.cgi/fastcgi-isapi/>
http://cvs.php.net/viewcvs.cgi/fastcgi-isapi/). 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 have
submitted these to the PHP project and they are reviewing them.) 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:
 
HKEY_LOCAL_MACHINE\SOFTWARE\FASTCGI\.pl 

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: 

 <http://www.simongibson.com/intranet/php2003/>
http://www.simongibson.com/intranet/php2003/ 

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: 

 <http://www.dependencywalker.com/> http://www.dependencywalker.com/ 

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

Mike 

--- FCGIProcMgr.cpp     Thu Apr 27 14:46:38 2006 
+++ FCGIProcMgr.cpp.new 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,
sizeof(proc->args)-1); 
+       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) { 
                proc->env.putEnv("_FCGI_NTAUTH_IMPERSONATE_=1"); 

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

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

+#if !defined (INVALID_FILE_ATTRIBUTES) 
+#define INVALID_FILE_ATTRIBUTES ((DWORD)-1) 
+#endif 
+ 
 extern void InitiateServers(char *szExtension); 
 extern void CheckServers(char *szExtension);

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.