[prev] [thread] [next] [Date index for 2005/05/10]
Hello folks, This is for a HTML::Mason application but i believe its a problem with my mod_perl/apache configuration... I am trying to configure my apache/handler to run multiple instances of the same application (one for each of our client). Basicly I need the following: 1. each client use the same 'comp_root'. (same application for all!) 2. each client connect to is own db (think I got that without much problems) 3. each client globals run in there own namespace (think I got it with the 'in_package' config) So client1 connect to client1.example.com, client2 connect to client2.example.com and so on. Here my current setup... I am really in need for advise on this one, this setup don't seem to work for an unknown reason. Apache 1.33 Mason 1.28 VirtualHost part of my apache config: ServerName 127.0.0.1 NameVirtualHost * <VirtualHost *> ServerName client1.example.com PerlSetVar ClientName client1 <LocationMatch "(\.html|\.txt|\.pl)$"> SetHandler perl-script PerlHandler MyApp::Mason </LocationMatch> <LocationMatch "(dhandler|autohandler|\.m(html|txt|pl))$"> SetHandler perl-script PerlInitHandler Apache::Constants::NOT_FOUND </LocationMatch> </VirtualHost> <VirtualHost *> ServerName client2.example.com PerlSetVar ClientName client2 <LocationMatch "(\.html|\.txt|\.pl)$"> SetHandler perl-script PerlHandler MyApp::Mason </LocationMatch> <LocationMatch "(dhandler|autohandler|\.m(html|txt|pl))$"> SetHandler perl-script PerlInitHandler Apache::Constants::NOT_FOUND </LocationMatch> </VirtualHost> Handler.pl: #!/usr/bin/perl package MyApp::Mason; # Pragmas use strict; use warnings; # Modules use Apache::Constants; use HTML::Mason::ApacheHandler; # ApacheHandler global hash my %ah; # List of modules that you want to use within components. { package HTML::Mason::Commands; use Apache::DBI; use DBI; use DBD::mysql; use Data::Dumper; use LWP::UserAgent; } foreach my $client ( qw(client1 client2) ) { $ah{$client} = HTML::Mason::ApacheHandler->new ( in_package => "MyApp::$client", args_method => 'CGI', comp_root => 'C:\Internet\Apache.v1.33\htdocs', data_dir => 'C:\Internet\Apache.v1.33\temp', allow_globals => ['$dbh', '%session', '$client'], ); } sub handler { my $r = shift; my $client = $r->dir_config('ClientName'); return DECLINED unless exists $ah{$client}; { no strict 'refs'; local ${"MyApp::${client}::dbh"} = DBI->connect( "DBI:mysql:host=127.0.0.1;dbname=$client", 'root', 'password' ) or die "Cannot connect to database: $DBI::errstr!\n"; } my $status = $ah{$client}->handle_request($r); return $status; } 1;
![]() |
Running multiple instances of the same app with vhost's
|
![]() |
![]() |
Re: Running multiple instances of the same app with vhost's
|
Generated at 06:57 on 17 May 2005 by mariachi v0.52