You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Roman <ro...@free.fr> on 2005/03/02 16:18:53 UTC

Dynamic VirtualHost's

Hi all,
Is it possible to dynamically create VirtualHost's using mod_perl, 
taking the value of each directive in a database ? If it is, how can I 
do exactly please ?
Because actually, I'm doing things like :
-----
push(@{ $VirtualHost{'*:80'} }, \%conf);
-----
It works well, but with this method I must periodically restart Apache 
and I think it uses as many memory as when we write 
<VirtualHost></VirtualHost> 's in the Apache .conf file, does it ? 
(there will be maybe thousands of VirtualHost's)

Thank you in advance,
Roman.


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.5.7 - Release Date: 01/03/2005


Re: Dynamic VirtualHost's

Posted by David J Radunz <da...@staff.netspace.net.au>.
Althou its not ideal - the whole procedure can be done dynamically by
setting up just one VirtualHost and adding a perl handler to dynamically
set the document_root :) But depending what sort of hosting your doing
this solution may not be the best for you. For this to work you will
need to turn canocal names off.

DJ

On Wed, 2005-03-02 at 16:18 +0100, Roman wrote:
> Hi all,
> Is it possible to dynamically create VirtualHost's using mod_perl, 
> taking the value of each directive in a database ? If it is, how can I 
> do exactly please ?
> Because actually, I'm doing things like :
> -----
> push(@{ $VirtualHost{'*:80'} }, \%conf);
> -----
> It works well, but with this method I must periodically restart Apache 
> and I think it uses as many memory as when we write 
> <VirtualHost></VirtualHost> 's in the Apache .conf file, does it ? 
> (there will be maybe thousands of VirtualHost's)
> 
> Thank you in advance,
> Roman.
> 
> 

This email and any files transmitted with it are confidential and intended solely for the 
use of the individual or entity to whom they are addressed. Please notify the sender 
immediately by email if you have received this email by mistake and delete this email 
from your system. Please note that any views or opinions presented in this email are solely
 those of the author and do not necessarily represent those of the organisation. 
Finally, the recipient should check this email and any attachments for the presence of 
viruses. The organisation accepts no liability for any damage caused by any virus 
transmitted by this email. 


Re: Dynamic VirtualHost's

Posted by Marc Gràcia <mg...@oasyssoft.com>.
Ooops cross-thread-answering..  :)
Stas posted few messages above that the reload can be done inside
mod_perl , so it's even easier to setup...

Goehring, Chuck, RCI - San Diego wrote:
>  
> Well, when I use cgis that run under Registry, if  I modify a pm file,
> I have to restart the web server before I see changes. 

Chuck, use Apache::Reload and you won't have to restart the server.
http://modperlbook.org/html/ch06_08.html

-- 
__________________________________________________________________
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



El dj 03 de 03 del 2005 a les 11:44 +0100, en/na Marc Gràcia va
escriure:
> Is not necesary to restart apache... A "graceful" do the job.
> I'm using this approach, and is really quick  and  not visible for end
> users. (I have 50 or so virtualhosts, so maybe in your case can be a
> little slower). 
> Maybe some time after the "graceful" we have a little more load
> (apache is replacing processes an all this) but works like a charm.
> I think this is easily tested in your setup. 
> 
> 
> El dc 02 de 03 del 2005 a les 16:18 +0100, en/na Roman va escriure: 
> > Hi all,
> > Is it possible to dynamically create VirtualHost's using mod_perl, 
> > taking the value of each directive in a database ? If it is, how can I 
> > do exactly please ?
> > Because actually, I'm doing things like :
> > -----
> > push(@{ $VirtualHost{'*:80'} }, \%conf);
> > -----
> > It works well, but with this method I must periodically restart Apache 
> > and I think it uses as many memory as when we write 
> > <VirtualHost></VirtualHost> 's in the Apache .conf file, does it ? 
> > (there will be maybe thousands of VirtualHost's)
> > 
> > Thank you in advance,
> > Roman.
> > 
> > 
> -- 
> Marc Gràcia <mg...@oasyssoft.com>


Re: Dynamic VirtualHost's

Posted by Marc Gràcia <mg...@oasyssoft.com>.
Well, In our case, the server doesn't have any mod_perl apps. Only uses
mod_perl (Or perl sections, i don't really know if it's the same....) to
dinamicaly generate the virtualhosts. 
That apache2 acts as a reverse proxy to controls several httpd servers
in the private lan with the mod_perl apps. It's a wonderfull option, if
you need it. Works really well, and adds some more features as caching,
warning pages while servers ar stopped or in maintenance.... And also
the most important part, the internal servers always use high bandwith
connections, so the session blocking time is lower.


El dv 04 de 03 del 2005 a les 15:37 +1100, en/na David J Radunz va
escriure:

> On Thu, 2005-03-03 at 11:44 +0100, Marc Gràcia wrote:
> > Is not necesary to restart apache... A "graceful" do the job.
> > I'm using this approach, and is really quick  and  not visible for end
> > users. (I have 50 or so virtualhosts, so maybe in your case can be a
> > little slower). 
> > Maybe some time after the "graceful" we have a little more load
> > (apache is replacing processes an all this) but works like a charm.
> > I think this is easily tested in your setup. 
> > 
> > 
> 
> Strange - Ive always found that 'graceful' (althou a great option) plays
> havoc with mod_perl applications.
> 
> > El dc 02 de 03 del 2005 a les 16:18 +0100, en/na Roman va escriure: 
> > > Hi all,
> > > Is it possible to dynamically create VirtualHost's using mod_perl, 
> > > taking the value of each directive in a database ? If it is, how can I 
> > > do exactly please ?
> > > Because actually, I'm doing things like :
> > > -----
> > > push(@{ $VirtualHost{'*:80'} }, \%conf);
> > > -----
> > > It works well, but with this method I must periodically restart Apache 
> > > and I think it uses as many memory as when we write 
> > > <VirtualHost></VirtualHost> 's in the Apache .conf file, does it ? 
> > > (there will be maybe thousands of VirtualHost's)
> > > 
> > > Thank you in advance,
> > > Roman.
> > > 
> > > 
> > -- 
> > Marc Gràcia <mg...@oasyssoft.com>
> 
> This email and any files transmitted with it are confidential and intended solely for the 
> use of the individual or entity to whom they are addressed. Please notify the sender 
> immediately by email if you have received this email by mistake and delete this email 
> from your system. Please note that any views or opinions presented in this email are solely
>  those of the author and do not necessarily represent those of the organisation. 
> Finally, the recipient should check this email and any attachments for the presence of 
> viruses. The organisation accepts no liability for any damage caused by any virus 
> transmitted by this email. 
> 
> 

Re: Dynamic VirtualHost's

Posted by David J Radunz <da...@staff.netspace.net.au>.
On Thu, 2005-03-03 at 11:44 +0100, Marc Gràcia wrote:
> Is not necesary to restart apache... A "graceful" do the job.
> I'm using this approach, and is really quick  and  not visible for end
> users. (I have 50 or so virtualhosts, so maybe in your case can be a
> little slower). 
> Maybe some time after the "graceful" we have a little more load
> (apache is replacing processes an all this) but works like a charm.
> I think this is easily tested in your setup. 
> 
> 

Strange - Ive always found that 'graceful' (althou a great option) plays
havoc with mod_perl applications.

> El dc 02 de 03 del 2005 a les 16:18 +0100, en/na Roman va escriure: 
> > Hi all,
> > Is it possible to dynamically create VirtualHost's using mod_perl, 
> > taking the value of each directive in a database ? If it is, how can I 
> > do exactly please ?
> > Because actually, I'm doing things like :
> > -----
> > push(@{ $VirtualHost{'*:80'} }, \%conf);
> > -----
> > It works well, but with this method I must periodically restart Apache 
> > and I think it uses as many memory as when we write 
> > <VirtualHost></VirtualHost> 's in the Apache .conf file, does it ? 
> > (there will be maybe thousands of VirtualHost's)
> > 
> > Thank you in advance,
> > Roman.
> > 
> > 
> -- 
> Marc Gràcia <mg...@oasyssoft.com>

This email and any files transmitted with it are confidential and intended solely for the 
use of the individual or entity to whom they are addressed. Please notify the sender 
immediately by email if you have received this email by mistake and delete this email 
from your system. Please note that any views or opinions presented in this email are solely
 those of the author and do not necessarily represent those of the organisation. 
Finally, the recipient should check this email and any attachments for the presence of 
viruses. The organisation accepts no liability for any damage caused by any virus 
transmitted by this email. 


Re: Dynamic VirtualHost's

Posted by Marc Gràcia <mg...@oasyssoft.com>.
Is not necesary to restart apache... A "graceful" do the job.
I'm using this approach, and is really quick  and  not visible for end
users. (I have 50 or so virtualhosts, so maybe in your case can be a
little slower). 
Maybe some time after the "graceful" we have a little more load (apache
is replacing processes an all this) but works like a charm.
I think this is easily tested in your setup. 


El dc 02 de 03 del 2005 a les 16:18 +0100, en/na Roman va escriure:

> Hi all,
> Is it possible to dynamically create VirtualHost's using mod_perl, 
> taking the value of each directive in a database ? If it is, how can I 
> do exactly please ?
> Because actually, I'm doing things like :
> -----
> push(@{ $VirtualHost{'*:80'} }, \%conf);
> -----
> It works well, but with this method I must periodically restart Apache 
> and I think it uses as many memory as when we write 
> <VirtualHost></VirtualHost> 's in the Apache .conf file, does it ? 
> (there will be maybe thousands of VirtualHost's)
> 
> Thank you in advance,
> Roman.
> 
> 

-- 
Marc Gràcia <mg...@oasyssoft.com>

Re: Dynamic VirtualHost's

Posted by Perrin Harkins <pe...@elem.com>.
On Wed, 2005-03-02 at 16:18 +0100, Roman wrote:
> Is it possible to dynamically create VirtualHost's using mod_perl, 
> taking the value of each directive in a database ?

It's possible to do this with mod_perl, but I'd suggest you look at
mod_vhost_dbi instead.  It's a better bet for simple mass hosting
controlled by a database.

http://www.outoforder.cc/projects/apache/mod_vhost_dbi/

- Perrin