You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Bruce Johnson <jo...@Pharmacy.Arizona.EDU> on 2020/06/03 17:53:02 UTC
Weird issue with DBI mysql driver under mod_perl
I’m migrating a bunch of old cgi web apps to a new server (CentOS8) and running them under mod_perl.
one of them uses the DBD::mysql driver and when running under mod_perl only I get the strange error:
[Tue Jun 02 10:29:32.289698 2020] [:error] [pid 3729:tid 140210163652352] DBD::mysql initialisation failed: Can't locate object method "driver" via package "DBD::mysql" at /usr/lib64/perl5/vendor_perl/DBI.pm line 827.\n\nPerhaps the capitalisation of DBD 'mysql' isn't right. at /home/allwebfiles/perl/badges/choose.pl line 54.\n
This is a really wrong error, since the DBD/mysql.pm script quite clearly has a sub called ‘driver’ and there is no isssue of capitalization in the database handle creation.
the handler code in my perl.conf file is pretty simple:
<Location /badges/>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
PerlSendHeader On
allow from all
</Location>
And it works for other locations, although this is the only one using the mysql driver, but DBD::Oracle works fine for a number of other scripts.
If I comment out the handler in perl.conf, add it as a ScriptAlias to run as a CGI script, it works. If I run the script itself on the command line, it works. I only get that error when I run it with a mod_perl handler.
I've asked on the DBI list and no one there has any ideas...
--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group
Institutions do not have opinions, merely customs
Re: Weird issue with DBI mysql driver under mod_perl
Posted by Bruce Johnson <jo...@Pharmacy.Arizona.EDU>.
Now this was *really* weird.
I fixed the DBD::mysql problem by adding '/usr/lib64/perl5/vendor_perl’ to my ‘use’ statement in startup.pl, EVEN THOUGH it’s already in @INC, and DBD::mysql lives in /usr/local/lib64/perl5/DBD
DBI lives in that directory, but other scripts using DBI and DBD::Oracle were working as expected.
Now my test script shows '/usr/lib64/perl5/vendor_perl’ twice in @INC:
@INC
/home/allwebfiles/perl/LocalModules
/usr/lib64/perl5
/usr/share/perl5
/usr/local/lib64/perl5
/usr/lib64/perl5/vendor_perl
/usr/lib64/perl5/vendor_perl/Bundle
/usr/local/share/perl5
/usr/share/perl5/vendor_perl
/etc/httpd
So possibly an order in @INC thing? The above list is an un-sorted traversal of @INC, but since there’s only one place that you can find DBD::mysql I don’t understand how that could be an issue.
On Jun 3, 2020, at 12:54 PM, Bill Hess <bh...@techrg.com>> wrote:
Do you set PERL5LIB in the environment who is running Apache?
If not - then maybe try to set the path where you have DBD::MySQL installed
Your line 'use lib ....' should handle this but we have seen issues in the past when setting it on the fly like this - so using PERL5LIB has solved issues for us vs using 'use lib ...'
--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group
Institutions do not have opinions, merely customs
Re: Weird issue with DBI mysql driver under mod_perl
Posted by Bruce Johnson <jo...@Pharmacy.Arizona.EDU>.
Yes I have that set, and my PerlRequire file is pretty minimal:
#!/usr/bin/perl
use lib qw(/usr/lib64/perl5 /usr/share/perl5 /usr/local/lib64/perl5 /home/allwebfiles/perl/LocalModules /usr/lib64/perl5/vendor_perl/Bundle);
use CGI ();
use PharmApps::CleanCGI ();
CGI->compile(':all');
use DBI ();
use Apache2;
1;
This is similar to the one I’ve used on another production server for some time without issues, but that one doesn’t use MySQL, only Oracle.
As I said other mod_perl applications on this same server are working as expected; this issue seems to be strictly with the DBD::mysql file for DBI.
On Jun 3, 2020, at 11:25 AM, Bill Hess <bh...@techrg.com>> wrote:
This MIGHT be the problem...
If you have some lines like this in your Apache httpd.conf
PerlModule mod_perl2
PerlRequire /path/to/my/conf/files/apache.pl<http://apache.pl/>
And the file /path/to/my/conf/files/apache.pl<http://apache.pl/> should look something like
#!/usr/bin/perl
use ModPerl::Util ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::RequestUtil ();
use Apache2::ServerRec ();
use Apache2::ServerUtil ();
use Apache2::Connection ();
use Apache2::Log ();
use Apache2::Const -compile => ':common';
use APR::Const -compile => ':common';
use APR::Table ();
use DBI;
# Perhaps some other modules you are using in your CGI scripts...
1;
On Wed, Jun 3, 2020 at 1:53 PM Bruce Johnson <jo...@pharmacy.arizona.edu>> wrote:
I’m migrating a bunch of old cgi web apps to a new server (CentOS8) and running them under mod_perl.
one of them uses the DBD::mysql driver and when running under mod_perl only I get the strange error:
[Tue Jun 02 10:29:32.289698 2020] [:error] [pid 3729:tid 140210163652352] DBD::mysql initialisation failed: Can't locate object method "driver" via package "DBD::mysql" at /usr/lib64/perl5/vendor_perl/DBI.pm line 827.\n\nPerhaps the capitalisation of DBD 'mysql' isn't right. at /home/allwebfiles/perl/badges/choose.pl<http://choose.pl/> line 54.\n
This is a really wrong error, since the DBD/mysql.pm<http://mysql.pm/> script quite clearly has a sub called ‘driver’ and there is no isssue of capitalization in the database handle creation.
the handler code in my perl.conf file is pretty simple:
<Location /badges/>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
PerlSendHeader On
allow from all
</Location>
And it works for other locations, although this is the only one using the mysql driver, but DBD::Oracle works fine for a number of other scripts.
If I comment out the handler in perl.conf, add it as a ScriptAlias to run as a CGI script, it works. If I run the script itself on the command line, it works. I only get that error when I run it with a mod_perl handler.
I've asked on the DBI list and no one there has any ideas...
--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group
Institutions do not have opinions, merely customs
--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group
Institutions do not have opinions, merely customs
Re: Weird issue with DBI mysql driver under mod_perl
Posted by Bill Hess <bh...@techrg.com>.
This MIGHT be the problem...
If you have some lines like this in your Apache httpd.conf
PerlModule mod_perl2
PerlRequire /path/to/my/conf/files/apache.pl
And the file /path/to/my/conf/files/apache.pl should look something like
#!/usr/bin/perl
use ModPerl::Util ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::RequestUtil ();
use Apache2::ServerRec ();
use Apache2::ServerUtil ();
use Apache2::Connection ();
use Apache2::Log ();
use Apache2::Const -compile => ':common';
use APR::Const -compile => ':common';
use APR::Table ();
use DBI;
# Perhaps some other modules you are using in your CGI scripts...
1;
On Wed, Jun 3, 2020 at 1:53 PM Bruce Johnson <jo...@pharmacy.arizona.edu>
wrote:
> I’m migrating a bunch of old cgi web apps to a new server (CentOS8) and
> running them under mod_perl.
>
> one of them uses the DBD::mysql driver and when running under mod_perl
> only I get the strange error:
>
> [Tue Jun 02 10:29:32.289698 2020] [:error] [pid 3729:tid 140210163652352]
> DBD::mysql initialisation failed: Can't locate object method "driver" via
> package "DBD::mysql" at /usr/lib64/perl5/vendor_perl/DBI.pm line
> 827.\n\nPerhaps the capitalisation of DBD 'mysql' isn't right. at
> /home/allwebfiles/perl/badges/choose.pl line 54.\n
>
> This is a really wrong error, since the DBD/mysql.pm script quite
> clearly has a sub called ‘driver’ and there is no isssue of capitalization
> in the database handle creation.
>
> the handler code in my perl.conf file is pretty simple:
>
> <Location /badges/>
> SetHandler perl-script
> PerlHandler ModPerl::Registry
> Options ExecCGI
> PerlSendHeader On
> allow from all
> </Location>
>
> And it works for other locations, although this is the only one using the
> mysql driver, but DBD::Oracle works fine for a number of other scripts.
>
> If I comment out the handler in perl.conf, add it as a ScriptAlias to run
> as a CGI script, it works. If I run the script itself on the command line,
> it works. I only get that error when I run it with a mod_perl handler.
>
> I've asked on the DBI list and no one there has any ideas...
>
> --
> Bruce Johnson
> University of Arizona
> College of Pharmacy
> Information Technology Group
>
> Institutions do not have opinions, merely customs
>
>
>