apache perl

修改httpd.conf



ScriptAlias /cgi-bin/ "D:/Apache2.2/cgi-bin/"

<Directory "D:/Apache2.2/cgi-bin">
    AllowOverride All
    Options All
    Order allow,deny
    Allow from All
</Directory>


AddHandler cgi-script .cgi .pl

重启
访问:http://localhost:81/cgi-bin/printenv.pl
 

 printenv.pl:

#!D:/Perl/bin/perl.exe
##
##  printenv -- demo CGI program which just prints its environment
##


print "Content-type: text/plain; charset=iso-8859-1\n\n";
foreach $var (sort(keys(%ENV))) {
    $val = $ENV{$var};
    $val =~ s|\n|\\n|g;
    $val =~ s|"|\\"|g;
    print "${var}=\"${val}\"\n";
}