Howdy,

 

I work for a hosting company and we handle literally millions of virtual hosts, mostly differing only by their document_root.  We are currently using apache 1.3.x, but would like to move to apache 2.  I would like to be able in some handler to set document root, return DECLINED and have aliases and the directory index just work themselves out by the time I get around to serving the page.  A simple case is below.

 

in /etc/apache2/httpd.conf I put

 

PerlModule DocRoot

PerlMapToStorageHandler DocRoot

 

 

And then in DocRoot.pm

 

package DocRoot;

 

use strict;

use warnings;

 

use Apache::RequestRec ();

use Apache::Const -compile => qw(OK DECLINED);

 

sub handler {

  my $r = shift;

  $r->document_root(hostname2docroot($r->hostname));

 

  return Apache::DECLINED;

}

 

sub hostname2docroot {

  my $hostname = shift || die "need a hostname";

  return "/tmp/$hostname/";

}

 

1;

 

 

Of course, when I try $r->document_root I get

 

Can't locate object method "document_root" via package "Apache::RequestRec"

 

I am running Apache/2.0.52, and I noticed today there is Apache/2.0.53, but I don't think updating will matter.

 

For the record I brought this up with stas at a mod_perl bof at oscon and was told to mail the list and it might get resolved.  So, here, some few months later, is my email.

 

Thanks,

Earl

Reply via email to