Need help getting DBI to work under mod_perl

[prev] [thread] [next] [Date index for 2005/02/06]

From: Boysenberry Payne
Subject: Need help getting DBI to work under mod_perl
Date: 06:09 on 06 Feb 2005
--Apple-Mail-1-513933009
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

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() );

--Apple-Mail-1-513933009
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
	charset=US-ASCII

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:


<fontfamily><param>Arial</param><bigger><bigger>Can't connect to MySQL
server on 'localhost' (49)</bigger></bigger></fontfamily>


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() );


--Apple-Mail-1-513933009--

Need help getting DBI to work under mod_perl
Boysenberry Payne 06:09 on 06 Feb 2005

Re: Need help getting DBI to work under mod_perl
Boysenberry Payne 06:32 on 06 Feb 2005

Re: Need help getting DBI to work under mod_perl
Jay Scherrer 17:46 on 06 Feb 2005

Re: Need help getting DBI to work under mod_perl
Boysenberry Payne 22:16 on 06 Feb 2005

Re: Need help getting DBI to work under mod_perl
Boysenberry Payne 21:54 on 07 Feb 2005

Re: Need help getting DBI to work under mod_perl
Boysenberry Payne 18:46 on 06 Feb 2005

Re: Need help getting DBI to work under mod_perl
jonathan vanasco 14:43 on 06 Feb 2005

Generated at 21:37 on 09 Feb 2005 by mariachi v0.52