ERROR: missing environment variable 'SCRIPT_FILENAME'!

I've set up a Context pointing to my Perl scripts in /cgi-bin/ and everything works fine when the Type is CGI.

I've set up an External app pointing to lsperl.fpl, and linked that to the cgi-bin context (re-configured for Fast CGI). I've also confirmed that I have the FCGI module in my Perl path but, as soon as I try to run the Perl script I get the error.

I have set up a Fast CGI context called /cgi-bin/ which is linked to lsperld (this pretty much mirrors a Ruby on Rails setup (aside from the additional /dispatch.lsapi Static context) which does work).

I also have a Script Handler that specifies that .pl scripts should us the Fast CGI app.

However, I cannot see anywhere where /cgi-bin/ is mapped to /usr/local/httpd/cgi-bin. This didn't seem to matter when /cgi-bin/ was configured for vanilla CGI but I guess that, maybe, it does for Fast CGI.

Is the missing SCRIPT_FILENAME anything to do with this mapping of the /cgi-bin/ URL to a specific directory?

Incidently, if I remove the /cgi-bin/ context (matching your setup as far as I can tell), I then get a 404 Not Found error when I try and run a script. Looking in the error log it is showing that it cannot find a file in $VH_ROOT/cgi-bin/subdir/script.pl which also suggests that I need to do some sort of specific mapping of Script Root to /cgi-bin/. I've tried a Static context but it did not work.

I've just been doing a bit more experimentation, more closely copying the RoR setup I have and I have got it working (whether it is the correct way or not I don't know).

I have done the following:-

1. Created an External App called lsperld which runs lsperl.fpl
2. Created a Script Handler using lsperld and tied to all .pl scripts
3. (A new bit) Created a Fast CGI Context called lsperld which uses the Ext App lsperld
4. (Another new bit) Created a Static context, called /cgi-bin/ with a Location set to my CGI root. I have added the following re-write rules to this Static context (thereby linking it to the Fast CGI Context):-

I have set up a Fast CGI context called /cgi-bin/ which is linked to lsperld (this pretty much mirrors a Ruby on Rails setup (aside from the additional /dispatch.lsapi Static context) which does work).

Click to expand...

that's the problem, you should remove that.
If you want to run script through lsperld, you cannot set script as CGI or FCGI context. have to define a script handler for certain suffix like ".pl". then just use static context to map to the directory holding the script if need.