Hi everyone I have a problem that I can't figure. I've got two virtual hosts on one server. They both point to different directories as the DocumentRoots, however the mod_perl scripts in each directory are identical in name and content.
My problem is that SOMETIMES while accessing one virtual host, it will appear as though it is actually pulling data from the other virtual host's database (each virtual host uses a different database as shown below), however the URL does not change. All the links, etc, continue to point to the right domain, however the data is just wrong (and only intermittently). Here is how the two virtual hosts are declared in httpd.conf: ------------------------------------------------------------------------ <VirtualHost 12.34.56.78> ServerName demo.domain.com ServerAdmin [EMAIL PROTECTED] DocumentRoot /var/www/ors/demo ErrorLog /var/www/ors/logs/demo-error_log CustomLog /var/www/ors/logs/demo-access_log common PerlModule Apache::Registry PerlModule Apache::DBI PerlRequire /var/www/ors/demo/startup.pl PerlFreshRestart On PerlWarn on PerlSetVar DBASE DBI:mysql:host=localhost;database=rostering_demo PerlSetVar DBUSER username PerlSetVar DBPASS password <Directory /var/www/ors/demo> <Files ~ "\.pl$"> SetHandler perl-script PerlHandler Apache::Registry PerlSendHeader On </Files> Options ExecCGI Indexes MultiViews FollowSymLinks Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost 12.34.56.78> ServerName london.domain.com ServerAdmin [EMAIL PROTECTED] DocumentRoot /var/www/ors/london ErrorLog /var/www/ors/logs/london-error_log CustomLog /var/www/ors/logs/london-access_log common PerlModule Apache::Registry PerlModule Apache::DBI PerlRequire /var/www/ors/london/startup.pl PerlFreshRestart On PerlWarn on PerlSetVar DBASE DBI:mysql:host=localhost;database=rostering_london PerlSetVar DBUSER username PerlSetVar DBPASS password <Directory /var/www/ors/london> <Files ~ "\.pl$"> SetHandler perl-script PerlHandler Apache::Registry PerlSendHeader On </Files> Options ExecCGI Indexes MultiViews FollowSymLinks Order allow,deny Allow from all </Directory> </VirtualHost> ------------------------------------------------------------------------ The startup.pl files are like: ------------------------------------------------------------------------ #!/usr/bin/perl use Apache::DBI; use Apache::Registry; use Apache::RegistryLoader; use DBI; use DBD::mysql; use strict; Apache::RegistryLoader->new->handler("/roster.pl", "/var/www/ors/london/roster.pl", "london.domain.com"); Apache::DBI->connect_on_init('DBI:mysql:rostering_london:localhost', 'username', 'password', { RaiseError => 0, AutoCommit => 1, PrintError => 1 } ) or die $DBI::errstr; Apache::DBI->setPingTimeOut('DBI:mysql:rostering_london:localhost', 60); 1; ------------------------------------------------------------------------ (and the other is identical other than the handler and connect_on_init lines) roster.pl is the main script, which simply use's a package in ./ORS/ and then calls its main() sub. The main() sub in this package then does: ------------------------------------------------------------------------ use Apache; my $r = Apache->request; $dbstr = $r->dir_config('DBASE'); $dbuser = $r->dir_config('DBUSER'); $dbpass = $r->dir_config('DBPASS'); ------------------------------------------------------------------------ Every time I need database access, I simply do a: my $dbh = DBI->connect($dbstr,$dbuser,$dbpass) I've made these variables available throughout the entire package by using a use vars qw() in the BEGIN of this package, and I've made them available to other packages by exporting them. Below is how I did this: ------------------------------------------------------------------------ BEGIN { use vars qw( %config %help $dbstr $dbuser $dbpass $debug ); use Exporter (); @ORS::Main::ISA = qw(Exporter); @ORS::Main::EXPORT_OK = qw( %config %help $dbstr $dbuser $dbpass $debug ); } use vars @ORS::Main::EXPORT_OK; use vars qw/$action/; use ORS::Subs qw(:DEFAULT); sub main { ------------------------------------------------------------------------ They are then imported into other packages with: ------------------------------------------------------------------------ BEGIN { # Import some variables use vars qw( %config %help $dbstr $dbuser $dbpass $debug ); use ORS::Main qw( %config %help $dbstr $dbuser $dbpass $debug ); } ------------------------------------------------------------------------ I hope I have provided all the info I need... I've been working on this software for about 12 months flawlessly and have only just tried using it on multiple virtual hosts to encounter this problem. I'm sure its more my methodology than anything so any help/pointers on how best to do this would be great! Thanks, Brett Randall. -- Report problems: 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