然后在 perl.conf 或 httpd.conf 里写:
package Apache2::F_H1;use Apache2::RequestRec;
use Apache2::RequestIO;
use Apache2::Const -compile => qw(OK);sub handler {
my $r = shift;
$r->content_type('text/html');
$r->print('Hello World!');
return Apache2::Const::OK;
}1;
<Perl>
use lib 'E:/modperl';
</Perl>PerlModule Apache2::F_H1
<Location /h1>
SetHandler perl-script
PerlResponseHandler Apache2::F_H1
</Location>
package Apache2::F_H2;这样我们可以在 perl.conf 里这么写:sub kissme {
my $r = shift;
$r->content_type('text/html');
$r->print('Hello World!');
return Apache2::Const::OK;
}1;
PerlModule Apache2::F_H2Handler 时指定了 kissme.
<Location /h2>
SetHandler modperl
PerlResponseHandler Apache2::F_H2::kissme
</Location>
而这里没有那三个 use Apache2::*; 也能正常运行是因为 perl.conf 里 PerlRequire "C:/Apache2/conf/startup.pl", 且 startup.pl 载入了这一系列模块(包括这三)。
而 SetHandler 为什么即可以用 perl-script 又可以用 modperl 则参考 mod_perl 配置的一些指令.
这就是我们最简单的 Hello, World! 至此,我们可以访问 http://localhost/h2 或 h1 来享受我们的成果。
评论加载中…
![]() |