You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Philip Mak <pm...@aaanime.net> on 2004/01/25 00:38:15 UTC

PerlRequire's access to httpd.conf variables

In the following situation:

<VirtualHost 1.2.3.4>
ServerName site1.com
PerlSetVar Global /home/site1/global
PerlRequire site1.pl
</VirtualHost>

<VirtualHost 1.2.3.4>
ServerName site2.com
PerlSetVar Global /home/site2/global
PerlRequire site2.pl
</VirtualHost>

With the above example httpd.conf, is there a way site1.pl can read
the PerlSetVar Global and see "/home/site1/global", while site2.pl can
read it and see "/home/site2/global"? Or is this information not
available yet during the startup sequence?

-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: PerlRequire's access to httpd.conf variables

Posted by Stas Bekman <st...@stason.org>.
Philip Mak wrote:
> In the following situation:
> 
> <VirtualHost 1.2.3.4>
> ServerName site1.com
> PerlSetVar Global /home/site1/global
> PerlRequire site1.pl
> </VirtualHost>
> 
> <VirtualHost 1.2.3.4>
> ServerName site2.com
> PerlSetVar Global /home/site2/global
> PerlRequire site2.pl
> </VirtualHost>
> 
> With the above example httpd.conf, is there a way site1.pl can read
> the PerlSetVar Global and see "/home/site1/global", while site2.pl can
> read it and see "/home/site2/global"? Or is this information not
> available yet during the startup sequence?

It'd be helpful if you have mentioned which mp generation you are talking 
about, Philip.

At the moment in mp2 you have no way to access the vhost server record in 
PerlRequire unless you traverse the linked list of servers. Apache->server 
gives you the base server. I think it does the same in mp1, but I don't remember.

You are much better off using Perl sections, where you are independent of 
Apache and have everything in perl, and you have a full control of what's 
happening.

e.g.:

<VirtualHost 1.2.3.4>
ServerName site1.com
<Perl>
require "site1.pl";
foo::bar::init(global => "/home/site1/global")
</Perl>
</VirtualHost>

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html