Page loader updates to work with mod_perl 2.x:

- Give example conf file for mod_perl 2 in README.txt
- Use RegistryPrefork handler to emulate mod_perl 1.x's chdir() behavior
- Add version of RegistryPrefork.pm backported for mod_perl <= 1.99_08
- Don't autoflush output in the middle of sending HTTP headers; it confuses mod_perl's ParseHeaders
- Comment out a warn() that's not really needed

r=jrgm
This commit is contained in:
bryner%brianryner.com 2003-08-30 03:43:33 +00:00
parent 4ee83fcf13
commit 7868977652
3 changed files with 61 additions and 8 deletions

View File

@ -91,9 +91,6 @@ for (@modules) {
HTML::Tagset, version: 3.03
Digest::MD5, version: 2.24
I've also heard that installing with Apache 2.x requires a few changes,
although I don't know what they are. If you know, tell jrgm@netscape.com.
4) There is code to draw a sorted graph of the final results, but I have
disabled the place in 'report.pl' where its use would be triggered (look
for the comment). This is so that you can run this without having gone
@ -111,8 +108,10 @@ for (@modules) {
'GD::Text' and 'GD::Graph' from the CPAN shell.]
5) To set this up with Apache, create a directory in the cgi-bin for the web
server called e.g. 'page-loader' and then place this in the Apache
httpd.conf file to enable this for mod_perl (and then restart Apache).
server called e.g. 'page-loader'.
5a) For Apache 1.x/mod_perl 1.x, place this in the Apache httpd.conf file,
and skip to step 5c.
--8<--------------------------------------------------------------------
Alias /page-loader/ /var/www/cgi-bin/page-loader/
@ -124,7 +123,30 @@ Options +ExecCGI
</Location>
--8<--------------------------------------------------------------------
So, now you can run this as 'http://yourserver.domain.com/page-loader/loader.pl'
5b) If you're using Apache 2.x and mod_perl 1.99/2.x (tested with Red Hat 9),
place this in your perl.conf or httpd.conf:
--8<--------------------------------------------------------------------
Alias /page-loader/ /var/www/cgi-bin/page-loader/
<Location /page-loader>
SetHandler perl-script
PerlResponseHandler ModPerl::RegistryPrefork
PerlOptions +ParseHeaders
Options +ExecCGI
</Location>
--8<--------------------------------------------------------------------
If your mod_perl version is less than 1.99_09, then copy RegistryPrefork.pm
to your vendor_perl ModPerl directory (for example, on Red Hat 9, this is
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/ModPerl).
If you are using mod_perl 1.99_09 or above, grab RegistryPrefork.pm from
http://perl.apache.org/docs/2.0/user/porting/compat.html#C_Apache__Registry___C_Apache__PerlRun__and_Friends
and copy it to the vendor_perl directory as described above.
5c) When you're finished, restart Apache. Now you can run this as
'http://yourserver.domain.com/page-loader/loader.pl'
6) You need to create a subdirectory call 'db' under the 'page-loader'
directory. This subdirectory 'db' must be writeable by UID that Apache

View File

@ -0,0 +1,31 @@
package ModPerl::RegistryPrefork;
# RegistryPrefork.pm originally from
# http://perl.apache.org/docs/2.0/user/porting/compat.html#Code_Porting
# backported for mod_perl <= 1.99_08
use strict;
use warnings FATAL => 'all';
our $VERSION = '0.01';
use base qw(ModPerl::Registry);
use File::Basename ();
use constant FILENAME => 1;
sub handler : method {
my $class = (@_ >= 2) ? shift : __PACKAGE__;
my $r = shift;
return $class->new($r)->default_handler();
}
sub chdir_file {
my $file = @_ == 2 ? $_[1] : $_[0]->[FILENAME];
my $dir = File::Basename::dirname($file);
chdir $dir or die "Can't chdir to $dir: $!";
}
1;
__END__

View File

@ -175,7 +175,7 @@ sub outputPage {
my $basepath = $pagedata->httpbase;
$basepath =~ s/^http:/https:/i
if $ENV{SERVER_PORT} == 443;
warn "basepath: $basepath";
#warn "basepath: $basepath";
$basepath =~ s#^(.*?)(/base/)$#$1/nocache$2# if ($params{nocache});
$hook .= "<base href='". $basepath . $relpath .
"' xmlns='http://www.w3.org/1999/xhtml' />";
@ -205,10 +205,10 @@ sub outputPage {
$gResponseNow = [gettimeofday]; # for logging
{ # turn on output autoflush, locally in this block
local $| = 1;
print "Set-Cookie: moztest_SomeRandomCookie1=somerandomstring\n";
print "Set-Cookie: moztest_SomeRandomCookie2=somerandomstring\n";
print $contentTypeHeader;
local $| = 1;
print $content;
}