[sf-perl] mod_perl and DocumentRoot question

Fred Moyer fred at redhotpenguin.com
Thu Mar 8 18:27:31 PST 2007


spidaman at arachna.com wrote:
> You mean, like in httpd.conf
> <Location /batz>
>   SetHandler perl-script
>   PerlHandler Quinn::Batz
> </Location>

If you find yourself with too many of these pesky Location directives, 
you can use Apache::Dispatch 
(http://search.cpan.org/~phred/Apache-Dispatch-0.10_01/) to make your 
life easier (disclosure - I'm the maintainer).

Also if you don't need ENV variable access, you can use SetHandler 
modperl there to get a little speed boost.


> 
> and in perl space:
> package Quinn::Batz;
> use strict; # duh
> sub handler {
>     my $r = shift;
>     # do stuff with the Apache API
> }
> 1;
> 
> so that /batz is mapped to your perl module? The key here is that Apache 
> can resolve virtual paths with <Location> containers, including running 
> modperl handlers. 
> 
> On Thu, 8 Mar 2007, Quinn Weaver wrote:
>> I'm almost embarrassed to be asking this, but I've forgotten the
>> solution, and my old code belongs to someone else.  (Does this mean
>> I've forgotten more mod_perl than most hackers know? ;) ) I've checked
>> the mod_perl Cookbook and run some searches, but to no avail.
>>
>> The problem is that Apache expects me to have a path in my DocumentRoot
>> for each URL I support.  For instance, if I have
>>
>> http://www.example.com/foo/bar/
>> http://www.example.com/batz/
>>
>> Then it expects there to be directories
>>
>> /var/www/foo/bar
>> /var/www/batz
>>
>> This is silly, because my PerlHandler is generating the content--it's not
>> stored in static files on disk.  Moreover, I have dynamically generated URLs
>> like http://www.example.com/user/quinn/edit .
>>
>> What is the solution to this dumb problem?  Somebody throw me a rope. ;)
>>
>> Thanks,
>>
>>
> 



More information about the SanFrancisco-pm mailing list