1 package PLP::Backend::Apache;
10 defined $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2
15 require Apache2::Const;
16 require Apache2::RequestRec;
17 require Apache2::RequestUtil;
18 require Apache2::RequestIO;
19 Apache2::Const->import(-compile => qw(
20 HTTP_NOT_FOUND HTTP_FORBIDDEN OK
23 require Apache::Constants;
29 # mod_perl initializer: returns 0 on success, Apache error code on failure
33 $PLP::print = 'PLP::Backend::Apache::print';
36 $ENV{PLP_FILENAME} = my $filename = $r->filename;
38 unless (-f $filename) {
39 return MP2 ? Apache2::Const::HTTP_NOT_FOUND() : Apache::Constants::NOT_FOUND();
42 return MP2 ? Apache2::Const::HTTP_FORBIDDEN() : Apache::Constants::FORBIDDEN();
45 $ENV{PLP_NAME} = $r->uri;
47 $PLP::use_cache = $r->dir_config('PLPcache') !~ /^off$/i;
48 #S $PLP::use_safe = $r->dir_config('PLPsafe') =~ /^on$/i;
49 my $path = $r->filename();
50 my ($file, $dir) = File::Basename::fileparse($path);
53 $PLP::code = PLP::source($file, 0, undef, $path);
60 $r->read(my $data, $bytes);
64 # FAST printing under mod_perl
66 return unless grep length, @_;
67 PLP::sendheaders() unless $PLP::sentheaders;
71 # This is the mod_perl handler.
74 if (my $ret = init($_[0])) {
80 return MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
87 PLP::Backend::Apache - Apache mod_perl interface for PLP
91 Naturally, you'll need to enable I<mod_perl>:
93 apache-modconf apache enable mod_perl
95 Setup F<httpd.conf> (often just create a F</etc/apache2/conf.d/plp>) with:
99 SetHandler perl-script
100 PerlHandler PLP::Backend::Apache
102 PerlSetVar PLPcache On
108 =head2 PerlSetVar configuration directives
114 Sets caching B<On>/B<Off>. When caching, PLP saves your script in memory and
115 doesn't re-read and re-parse it if it hasn't changed. PLP will use more memory,
116 but will also run 50% faster.
118 B<On> is default, anything that isn't =~ /^off$/i is considered On.
124 Mischa POSLAWSKY <perl@shiar.org>
128 L<PLP>, L<PLP::Backend::FastCGI>, L<mod_perl>