Problem configuring isapi_fcgi.dll with IIS 5.0

"Todd S. Greene" <todd-UrzaMRejht/ENDDW/[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <003801c50a2e$8e38aee0$1a0aa8c0@BRIANOFFICE1>
Hello everyone, I'm totally new here and this is my first post.

Just to let you know, I'm not any kind of IIS or Apache administrator,
I'm a programmer and have been coding Perl since last summer. As I'm
starting to code more CGI applications, I'm realizing that I need to get
some kind of persistence going with the web server to improve CGI
performance. I started digging around with Google a few days ago on this
and from discussion I was reading I decided that FastCGI and "use FCGI"
in my Perl was the way to go.

Okay, great! But now what? I have already installed the FCGI module for
Perl on the web server, and I have to configure my web server (IIS 5.0
running on a Windows 2000 Server platform) to use FastCGI. So I do a
little more digging around, and I think I see that what I need to do is
download Shane Caraveo's isapi_fcgi.dll and do some configuration.

Hmmm... The documentation is a little hairy, a couple of items are not
explained well even though I do a lot of Googling, but I write down my
own summary of configuration steps, and then proceed. Here are the steps
I have written down and performed:

--------------------------------

1. Copy the "isapi_fcgi.dll" to an appropriate location, such as:
C:\Perl\fastcgi\

2. Make the following registry key:
HKEY_LOCAL_MACHINE/SOFTWARE/FASTCGI/.fcg

Add the following two values to this key:
AppPath C:\perl\bin\perl.exe
BindPath php-fcgi

[Note: When I read Shane Caraveo's readme file, he states that the
"BindPath" parameter is required, but not the "AppPath" value. This
doesn't seem right to me? But perhaps without AppPath the .dll is
searching for the Perl path from some other information location that
Windows has stored somewhere? I don't know, but I put the "AppPath"
value on my list as something I definitely need to put in the registry.
The "BindPath" is more problemmatic to me. First of all, I'm not really
sure what it is used for, and Shane does not explain it. The only
example he gives is with a value of "php-fcgi" and since he gives no
explanation for "BindPath" I have no idea if "php-fcgi" is a required
value or if I have some choice here and what any logical choices would
even be. Googling about this provides absolutely no further help -
indeed, I find other people asking the same question and getting zero
answers! Initially I even tried a value of "fcg-fcgi" (thinking that the
first 3 letters might correspong to the extension letters?), but I had
the same problem. Doesn't work.]

3. In IIS on Win2000, add the dll as an allowed ISAPI extension.

[Note: Again, it was through my googling that I picked up this
particular configuration step. That's all it said. My further experience
is this, but again please note that I'm NOT a web server administrator
by profession and I'm only dabbling in this as I need to to get things
set up for my web-related programs to work on some client sites. I hope
I have not misinterpreted the wording of this step, but what I did was
open the Properties for the website(s) I'm interested in configuring
this for (in other words, from what I saw I believe this step must be
performed *by site* in IIS) and then select the "ISAPI Filter" tab. Then
I added the isapi_fcgi.dll to the list (and you may very well have an
empty list to start with) where you basically just make a name for the
item (I just named it "fastcgi") and then give it the path to the dll,
such as, say "C:\perl\fastcgi\isapi_fcgi.dll".]

4. Open IIS, go to the cgi directory (or other relevant directory) and:
a. Edit Properties.
b. Click on Configuration button.
c. Add ".fcg" to the App Mappings with the executable
path set to the dll (i.e., the same path used in
step 3).

[Note here that one comment I read when googling stated explicitly that
you need to turn ON the "Check that file exists" flag for this one. So I
did.]

5. Restart IIS.

--------------------------------

Okay I've done all this, and still nothing works. Sometimes I get "The
page cannot be displayed" error (further text "The page you are looking
for is currently unavailable"), but other times I get nothing but a
single line of text that says "Server Error, unable to connect to
fastcgi server." Here is the text of my Perl program:

--------------------------------

#!/usr/bin/perl -wT

use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use FCGI;

sub main();

BEGIN
{
# for CGI app, set immediate flushing of file handle output buffers
select(STDOUT); $| = 1;
select(STDERR); $| = 1;

$ENV{'PATH'} = ''; # good CGI security practice

if (($^O eq "MSWin32") && ($#ARGV == -1))
{
$ENV{'SCRIPT_FILENAME'} = $0;
$ENV{'SCRIPT_FILENAME'} =~ s|\\|/|g;
$ENV{'PATH_INFO'} =~ /^$ENV{'SCRIPT_NAME'}(.*)$/;
my $path_info = $1;
$ENV{'SCRIPT_FILENAME'} =~ /^(.*)$ENV{'SCRIPT_NAME'}.*/;
my $document_root = $1;
$ENV{'PATH_TRANSLATED'} = $document_root . $path_info;
}
}

my $rc = main();
exit($rc);

###########################################################
# start of main
###########################################################
sub main() {
# initialization code
my $cnt = 0;

# response loop
while (FCGI::accept >= 0)
{
print("Content-type: text/html\r\n\r\n");
print("<head>\n<title>FastCGI Demo Page
(perl)</title>\n</head>\n<body>\n");
print("<h1>FastCGI Demo Page (perl)</h1>\n");
print("<p>This is coming from a FastCGI server.<br />\n");
print("Running on <em>$ENV{SERVER_NAME}</em> to
<em>$ENV{REMOTE_HOST}</em></p>\n");
++$cnt;
print("<p>This is connection number $cnt</p>\n");
print("</body>\n</html>\n");
}

return(0);
}
###########################################################
# end of main
###########################################################

--------------------------------

Note that if I run this as a regular CGI program (for which all I need
to do is change the extension from ".fcg" to ".cgi" which extension I
have already configured in IIS for my Perl CGI programs) it runs
perfectly fine, I don't even have to strip out the FCGI-related code,
but of course there is no persistence behavior (i.e., the connection
number displayed on the page is always 1).

I'm thinking that obviously other people have configured IIS to run
FastCGI-related Perl programs, using Shane Caraveo's "isapi_fcgi.dll",
and have been running along fine with more efficient CGI processing for
years, and there is something very simple I'm missing or have done not
quite right.

Can anyone using Perl and FastCGI with IIS, who is using the
isapi_fcgi.dll help me on this? I've tried to be very complete, but ask
me anything else if you like.

Regards,
Todd Greene

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