[thelist] Apache + ActivePerl CGI not working locally (CGI newbie configuration problem)

George Dillon <> Evolt! evolt at georgedillon.com
Mon Nov 5 10:04:50 CST 2001

I'm stumped again!

I'm trying to mimic my site's host environment locally so I can test CGIs
and then upload them to the server (ideally without having to remember to
alter any paths in the scripts before doing so).

I've managed to get my web pages accessing the virtual host cgi-bin for
simple "Hello World" type stuff, but when I try to call modules or create/
read/write to files it all fails badly - the browser never finishes loading
the page which calls the cgi and worse - Perl keeps running and prevents
the system (Win98) shutting down properly.

Details of the problematic code below the tip...

Any help would be much appreciated.



<tip type="Freeware site ripper">

In response to a recent thread asking about a site downloading tool I
recommended the freeware Webreaper ( http://www.webreaper.net/ ) which comes
with a powerful set of customisation features, including the ability to
completely customise the user-agent string.  Following djc's article on
Using Apache to stop bad robots (
http://evolt.org/article/rating/18/15126/index.html ) I was able to test my
bad bot blocking by cutting and pasting a known (and now blacklisted) bad
bot UA$ to webreaper and letting it try (and fail) to access my site.
A new version (9.6) has just been released and is just 957kb and $0.



I have Apache (1.3) in E:/Program Files/Apache Group/Apache/
Perl (ActivePerl 5,6,0,623) is in E:/Perl/
and my local test site is in F:/WWW/georgedillon.test/

In my httpd.conf I currently have this:

<START code type="from my httpd.conf file">

  ScriptAlias /cgi-bin/ "E:/Program Files/Apache Group/Apache/cgi-bin/"
  <Directory "E:/Program Files/Apache Group/Apache/cgi-bin">
     AllowOverride Options
     Options None
     Order allow,deny
     Allow from all

  DocumentRoot "f:/WWW/georgedillon.test"
  ServerName localtest
  ErrorLog "f:/WWW/georgedillon.test/logs/error.log"
  ScriptAlias /cgi-bin/ "f:/WWW/georgedillon.test/cgi-bin/"

</END Code>

I can get simple print "Hello World" to work from the site's cgi-bin, but
however I tweak it I can't get the following script (which logs hits on a
monthly basis and works fine on the host server) to work locally:

<START Code type="my cgi script">


#Determine which log file to use
$logdate= `date +"%Y%m.log"`;
chop ($logdate);
$log_file = "/home/myusername/public_html/mylogs/hits$logdate";

#Get date and format for the log
$getdate = `date +"%d/%b/%Y:%T"`;
chop ($getdate);

#Use domain name if available or IP if not
$domain = $ENV{'REMOTE_ADDR'};
chop ($domain);
if ($ENV{'REMOTE_HOST'} ne "")
 $domain = $ENV{'REMOTE_HOST'};

#Create entry to be written to the log file
$domain - - [$getdate] "$ENV{'REQUEST_METHOD'} $ENV{'DOCUMENT_URI'}

#Write entry to the log file
open (LOG, ">>$log_file") or open (LOG, ">$log_file");
flock LOG, 2;
print LOG "$LOGTHIS";
close (LOG);


</END code>

More information about the thelist mailing list