I'm able to run DBI->connect() fine when I run my .pl and .pm scripts as mod_cgi.
Once I set up my httpd.conf and startup.pl files it no longer works. I get the following:
Can't connect to MySQL server on 'localhost' (49)
I can't find what (49) means anywhere...
I've included my code below, maybe I'm missing something particular to mod_perl.
Again, all of the code has worked for both mod_cgi and as a stand alone using
perl updater.pl. (obviously, I changed the print statements as well as some of the
complexities surrounding the original intentions for the script.)
I running Mac OS X darwin, and get everything as showing correctly in the %ENV.
I'm stumped, been looking high and low for a couple of days...
I set httpd.conf up using the following:
Alias /perl/ "/Users/WebRoot/perl/"
PerlWarn On
PerlTaintCheck On
<Directory "/Users/WebRoot/perl">
AllowOverride None
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
Options ExecCGI Indexes FollowSymlinks
Order allow,deny
Allow from all
</Directory>
PerlRequire /etc/httpd/perl/startup.pl
PerlFreshRestart On
and in my startup.pl:
#!/usr/bin/perl
use strict;
BEGIN {
use Apache();
$ENV{ MOD_PERL } or die "not running under mod_perl!";
}
use Apache::Registry();
use Apache::Constants();
use CGI();
CGI->compile();
use CGI::Carp();
use Carp();
use DBI();
1;
and in my updater.pl script:
#!/usr/bin/perl -w
use DBI;
use strict;
use warnings;
my $r = Apache->request;
$r->print( header() );
$r->print( start_html( "My Perl Updater" ) );
my $dsn = "DBI:mysql:database=test";
my $test_db = eval{ DBI->connect( $dsn, "...", "...", { RaiseError => 1, PrintError => 1, AutoCommit => 1 } ) };
$r->print( $DBI::lasth->errstr );
$r->print( end_html() );
- Need help getting DBI to work under mod_perl Boysenberry Payne
- Re: Need help getting DBI to work under mod_perl Boysenberry Payne
- Re: Need help getting DBI to work under mod_perl Tom Schindl
- Re: Need help getting DBI to work under mod_per... Jay Scherrer
- Re: Need help getting DBI to work under mod... Rici Lake
- Re: Need help getting DBI to work under mod... Boysenberry Payne
- Re: Need help getting DBI to work under... Boysenberry Payne
- Re: Need help getting DBI to work under mod_per... Boysenberry Payne
- Re: Need help getting DBI to work under mod_perl jonathan vanasco