总算把mod_perl第一个页面配置出来了
写在这里
install忽略
1:创建Hello.pm
package Apache2::Hello;
use strict;
use Apache2::RequestRec (); # for $r->content_type
use Apache2::RequestIO (); # for $r->puts
use Apache2::Const -compile => ':common';
sub handler {
my $r = shift;
my $time = scalar localtime();
my $package = __PACKAGE__;
$r->content_type('text/html');
$r->puts(<<"END");
<HTML><BODY>
<H3>Hello</H3> Hello from <B>$package</B>!
The time is $time.
</BODY></HTML>
END
return Apache2::Const::OK;
}
1;
2:创建startup.pl
use strict;
use lib qw(/path/to/module/);
use Apache::Hello;
$ENV{MOD_PERL} or die "not running under mod_perl!";
3:编辑apache的httpd.conf或apache2.conf
加入
PerlRequire /path/to/startup.pl
SetHandler modperl
PerlHandler Apache2::Hello
4:startup.pl和Hello.pm的位置关系
/path/to/startup.pl
/path/to/Apache2/Hello.pm

没有评论:
发表评论