LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > CGI/Perl/Python > ERROR: missing environment variable 'SCRIPT_FILENAME'!

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2010, 04:27 PM
dougconran dougconran is offline
Member
 
Join Date: Jan 2010
Posts: 15
Default ERROR: missing environment variable 'SCRIPT_FILENAME'!

I'm trying to use Perl with Fast CGI but get the above error.

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.

The log files don't report any problems.

Can anyone suggest what I'm doing wrong?

Many thinaks

Doug
Reply With Quote
  #2  
Old 01-07-2010, 10:34 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Have you followed this
http://www.litespeedtech.com/how-tos.html#qa_perld
Reply With Quote
  #3  
Old 01-08-2010, 02:08 AM
dougconran dougconran is offline
Member
 
Join Date: Jan 2010
Posts: 15
Thanks for your quick reply.

Yes I have (with the one difference being that I installed FCGI.pm after installing Litespeed).

I don't have PHP running but do have Ruby on Rails configured (from following the RoR installation guide) which works fine.

I've also set FCGI_PERL_MAX_REQ=1000 in the Perl External App Environment variables.

I'm running v 4.0.11 of Litespeed and perl 5.10.1

TIA

Doug
Reply With Quote
  #4  
Old 01-08-2010, 10:54 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Our team member will try the similar setup see if we can reproduce it or not.
Reply With Quote
  #5  
Old 01-08-2010, 11:00 AM
dougconran dougconran is offline
Member
 
Join Date: Jan 2010
Posts: 15
Thanks

Doug
Reply With Quote
  #6  
Old 01-09-2010, 03:32 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,226
can you compare your perl External App settings with our demo page:
http://www.litespeedtech.com/litespeed-live-demos.html

go to the demo admin console,
Virtual Hosts -> demo -> External App ->lsperld

any difference with yours?
Reply With Quote
  #7  
Old 01-09-2010, 08:16 AM
dougconran dougconran is offline
Member
 
Join Date: Jan 2010
Posts: 15
Hi,

Although my setup was substantially the same as yours, I've made an exact copy of your setup but still l, immediately, get the same error.

However, I've noticed a few differences in other aspects of your setup. My www layout follows a rather ancient apache structure which is:-

Doc root = /usr/local/httpd/htdocs
CGI root = /usr/local/httpd/cgi-bin

with all of my scripts in sub directories under CGI root.

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.

Help!

TIA

Doug
Reply With Quote
  #8  
Old 01-09-2010, 08:33 AM
dougconran dougconran is offline
Member
 
Join Date: Jan 2010
Posts: 15
I think I've got it!!

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

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /lsperld [QSA,L]

and it seems to have been that which did the trick

I have no idea what the rewrite rules mean and would be grateful for any enlightenment.

Anyway, it seems to work, many thanks for your help.

Doug
Reply With Quote
  #9  
Old 01-09-2010, 08:35 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Quote:
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).
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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:18 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.