I have a new development system running Windows 7 Pro. I've loaded IIS 7.5 and ActivePerl 5.14.2 (x86) and followed the instructions widely available on the net (set up handler mappings using PerlEx30.dll, enable 32-bit). A simple Perl script runs fine
- once, but I've run into several problems which may or may not be related:
Some kind of state is being stored for sessions. I've sifted it down to the following: Perl variable values are stored from session to session. A simple script that prints, then increments an uninitialized variable returns successively higher values each
time the script is accessed from a browser. Different scripts accessing the same variable get the value most recently set by whichever script was most recently run. Everything is cleared if I restart IIS. This may be a Perl thing, but it happened even running
Perl 5.8.9 on Windows 7, whereas it didn't happen in my old XP environment. It also doesn't happen if you run the scripts from a command prompt. I know it's not cool to use uninitialized variables, but it tells me something weird is happening, and I wonder
what else is being stored.
use CGI::Carp qw{fatalsToBrowser}; isn't working at all, and none of the fixes I've seen on the Net help in the slightest.
The whole wwwroot directory and all subdirectories are "read only" and even "attrib" can't seem to clear that setting, making it very difficult to edit files in the websites below it.
Permissions seem odd. I am denied writing to a file, even though the directory I'm writing to has "full control" permission for "IIS_IUSRS (my-computer\IIS_IUSRS)". If I add a user "everyone" and give it full control, everything's fine.
I'm hoping that these are all related and are some kind of configuration issue I'm not aware of. It's also possible I made some errant setting that I didn't fix in the act of re-installing IIS and Perl. Any thoughts"
After MUCH experimentation I determined that the "state stored" problem (#1) could be solved by setting the DefaultAppPool "Recycling" setting to "Fixed number of requests" with a value of "1". "fatalsToBrowser" still doesn't work (the subroutine in the
CGI Carp module never gets called), although I can see on the browser what goes to the log by starting the code with "BEGIN {*STDERR = *STDOUT}". Is there some interaction with MOD_PERL? It seems to be installed although I don't think I need it.
use CGI::Carp qw(fatalsToBrowser);
BEGIN {
use CGI::Carp qw(carpout);
carpout(STDOUT);
}
You can also trying adding this subroutine and sprinkling calls to it in your CGI script:
sub logerr {
# Pepper your CGI scipt with a few of these to try to locate where (or if) script runs at all!
# logerr('I got to here: ',__LINE__);
# This routine uses the Perl caller function if this sub is called within another subroutine to show calling location better
my $msg=shift;
my $line=shift || '';
my %months = qw/Jan 1 Feb 2 Mar 3 Apr 4 May 5 Jun 6 Jul 7 Aug 8 Sep 9 Oct 10 Nov 11 Dec 12/;
my @now=split " ",scalar localtime; # Tue Jul 31 13:36:49 2012
my $day=sprintf("%02d",$now[2]);
my $month=sprintf("%02d",$months{$now[1]});
my $now="$now[4]-$month-$day $now[3]";
my $last_func = (caller(1))[3] || 'main';
my $last_line = (caller(1))[2] || $line;
# Cleanup log msg a little before writing!
$msg="'$last_func/$last_line' ".$msg;
$msg =~ s/ / /g;
$msg =~ s/ $//;
# You must create the sessions folder and grant modify rights to your IUSR user(s)
open(LOGERR, '>>C:/Windows/Temp/sessions/MyCGI_Error.log') or die "Error: $!\n";
print LOGERR "$now\t$0\t$msg\n";
close(LOGERR);
}
We've having upgrade troubles with 64-bit Server 2008 and 64-bit ActivePerl 5.14.2 too!
There is the perl sitecustomize.pl file. This is for setting up site wide features and enviroments for per website, etc. example: Here we set some missing ENV variables, push the STDERR to a per site log file, and add to the @INC path on a per site basis.
use lib;
if ((defined $ENV{PATH_TRANSLATED}) && ($ENV{PATH_TRANSLATED} =~ /(.:\\[^\\.]*\\[^\\.]*\\[^\\.]*)/)) {
$ENV{DOCUMENT_ROOT} = $1;
$ENV{DOCUMENT_ROOT} =~ s{\\}{/}g;
$home = $1 if ($ENV{PATH_TRANSLATED} =~ /(.:\\[^\\.]*\\[^\\.]*)/);
$home =~ s{\\}{/}g;
$perlmod = $home . '/perl-mod';
lib->import($perlmod);
$stderrlog = $home . '/logs/perl_errors.log';
open STDERR, ">>", $stderrlog;
}
if (length $ENV{SCRIPT_NAME}) {
$ENV{REQUEST_URI} = $ENV{SCRIPT_NAME};
$ENV{REQUEST_URI} = $ENV{SCRIPT_NAME} . '?' . $ENV{QUERY_STRING} if (length $ENV{QUERY_STRING});
$ENV{SCRIPT_FILENAME} = $ENV{DOCUMENT_ROOT} . $ENV{SCRIPT_NAME} if (defined $ENV{DOCUMENT_ROOT});
}
dave732
3 Posts
Variety of problems setting up IIS 7.5 with Perl
Apr 18, 2012 12:52 AM|LINK
I have a new development system running Windows 7 Pro. I've loaded IIS 7.5 and ActivePerl 5.14.2 (x86) and followed the instructions widely available on the net (set up handler mappings using PerlEx30.dll, enable 32-bit). A simple Perl script runs fine - once, but I've run into several problems which may or may not be related:
I'm hoping that these are all related and are some kind of configuration issue I'm not aware of. It's also possible I made some errant setting that I didn't fix in the act of re-installing IIS and Perl. Any thoughts"
session permissions insufficient rights caching cache Perl
dave732
3 Posts
Re: Variety of problems setting up IIS 7.5 with Perl
Apr 20, 2012 08:38 PM|LINK
After MUCH experimentation I determined that the "state stored" problem (#1) could be solved by setting the DefaultAppPool "Recycling" setting to "Fixed number of requests" with a value of "1". "fatalsToBrowser" still doesn't work (the subroutine in the CGI Carp module never gets called), although I can see on the browser what goes to the log by starting the code with "BEGIN {*STDERR = *STDOUT}". Is there some interaction with MOD_PERL? It seems to be installed although I don't think I need it.
aquacade
1 Post
Re: Variety of problems setting up IIS 7.5 with Perl
Sep 07, 2012 08:11 PM|LINK
Try adding this to the top of your CGI scripts:
use CGI::Carp qw(fatalsToBrowser);
BEGIN {
use CGI::Carp qw(carpout);
carpout(STDOUT);
}
You can also trying adding this subroutine and sprinkling calls to it in your CGI script:
sub logerr {
# Pepper your CGI scipt with a few of these to try to locate where (or if) script runs at all!
# logerr('I got to here: ',__LINE__);
# This routine uses the Perl caller function if this sub is called within another subroutine to show calling location better
my $msg=shift;
my $line=shift || '';
my %months = qw/Jan 1 Feb 2 Mar 3 Apr 4 May 5 Jun 6 Jul 7 Aug 8 Sep 9 Oct 10 Nov 11 Dec 12/;
my @now=split " ",scalar localtime; # Tue Jul 31 13:36:49 2012
my $day=sprintf("%02d",$now[2]);
my $month=sprintf("%02d",$months{$now[1]});
my $now="$now[4]-$month-$day $now[3]";
my $last_func = (caller(1))[3] || 'main';
my $last_line = (caller(1))[2] || $line;
# Cleanup log msg a little before writing!
$msg="'$last_func/$last_line' ".$msg;
$msg =~ s/ / /g;
$msg =~ s/ $//;
# You must create the sessions folder and grant modify rights to your IUSR user(s)
open(LOGERR, '>>C:/Windows/Temp/sessions/MyCGI_Error.log') or die "Error: $!\n";
print LOGERR "$now\t$0\t$msg\n";
close(LOGERR);
}
We've having upgrade troubles with 64-bit Server 2008 and 64-bit ActivePerl 5.14.2 too!
See these links too:
http://learn.iis.net/page.aspx/140/understanding-built-in-user-and-group-accounts-in-iis/
http://www.activestate.com/blog/2010/06/setting-iis-activeperl
If you migrated a 32-bit IIS earlier website config to IIS7+ you may also need to edit config files by hand located here on Server 2008:
C:\Windows\System32\inetsrv\config
Happy debugging!
Larry
server 2008 64 bit Perl CGI script problems ActivePerl
rossh
1 Post
Re: Variety of problems setting up IIS 7.5 with Perl
Apr 06, 2013 02:48 PM|LINK
There is the perl sitecustomize.pl file. This is for setting up site wide features and enviroments for per website, etc. example: Here we set some missing ENV variables, push the STDERR to a per site log file, and add to the @INC path on a per site basis.
use lib;
if ((defined $ENV{PATH_TRANSLATED}) && ($ENV{PATH_TRANSLATED} =~ /(.:\\[^\\.]*\\[^\\.]*\\[^\\.]*)/)) {
$ENV{DOCUMENT_ROOT} = $1;
$ENV{DOCUMENT_ROOT} =~ s{\\}{/}g;
$home = $1 if ($ENV{PATH_TRANSLATED} =~ /(.:\\[^\\.]*\\[^\\.]*)/);
$home =~ s{\\}{/}g;
$perlmod = $home . '/perl-mod';
lib->import($perlmod);
$stderrlog = $home . '/logs/perl_errors.log';
open STDERR, ">>", $stderrlog;
}
if (length $ENV{SCRIPT_NAME}) {
$ENV{REQUEST_URI} = $ENV{SCRIPT_NAME};
$ENV{REQUEST_URI} = $ENV{SCRIPT_NAME} . '?' . $ENV{QUERY_STRING} if (length $ENV{QUERY_STRING});
$ENV{SCRIPT_FILENAME} = $ENV{DOCUMENT_ROOT} . $ENV{SCRIPT_NAME} if (defined $ENV{DOCUMENT_ROOT});
}