Hi all, I'm new to mod_perl and the MySQL usage. I use mod_perl for mass virtual hosting through MySQL, I used this wonderful howto :
http://davidcoulson.net/writing/lxf/39/apache.pdf
So my httpd.conf contains that :
---------------------
<Perl>
package My::MySQLTrans;
use Apache::DBI;
use DBI;
use Apache::Constants qw(:common);
Apache::DBI->connect_on_init("DBI:mysql:iglou:localhost","iglou","xxxxx", {
PrintError => 1, #warn() on errors
RaiseError => 0, #don't die on error
AutoCommit => 1, #commit executes immediately
});
$dbh=DBI->connect("DBI:mysql:iglou:localhost","iglou","xxxxx");
sub get_hosting_info {
my $h = shift;
$h =~ tr/[A-Z]/[a-z]/;
if($h =~ /^www\.(.+)$/) {
$h=$1;
}
$sth=$dbh->prepare("SELECT dir FROM webaliases WHERE alias='".$h."'");
$dbh->{mysql_auto_reconnect} = 1;
$sth->execute();
if($row=$sth->fetchrow_hashref()) {
$h=$row->{dir};
}
$sth->finish();
$dbh->disconnect();
return $h;
}
sub handler {
my $r = shift;
$u = $r->uri;
if($u =~ /^\/icons\/.+/) {
$r->filename("/var/www".$u);
return OK;
}
$h=get_hosting_info($r->hostname);
if($1 eq "cgi-bin") {
$r->content_type("application/x-httpd-cgi");
}
$r->document_root("/var/www/users/".$h);
$r->filename("/var/www/users/".$h.$u);
$r->subprocess_env(VHOST=>$h);
return OK;
}
</Perl>
PerlTransHandler My::MySQLTrans
---------------------
I'm running OpenBSD 3.6 with Apache 1.29 and the needed perl modules (DBD::MySQL, DBI and some other ones) and when I just restarted the PC, Apache works well with these settings, but if I do an "apachectl graceful" or "apachectl restart", then I get this message in the error_log :
/usr/sbin/httpd:/usr/local/libdata/perl5/site_perl/i386-openbsd/auto/DBD/mysql/mysql.so: undefined symbol 'mysql_close' lazy binding failed!
(apache starts normally if I put another httpd.conf that doesn't contains any perl code, for exemple just mod_rewrite stuff)
It's the same if I try "apachectl stop" then "apachectl start" : apache writes it to the error_log and it doesn't start.
Where does this error come from ? How to fix it ? Or maybe there is an error in my perl code ? (or something to optimize or whatever)
Another thing is that before that I put "$dbh->{mysql_auto_reconnect} = 1;" in the code, I had errors like that in the error_log : "MySQL has gone away, fetchrow_hashref without execute()" (I don't remember exactly).
I googled and found that I must start MySQL with the "--skip-reconnect" option but MySQL doesn't work to start with that option. What must I do to fix that ?
Can you help me please ? I'm really lost.
Thanks in advance,
Best regards.