http://www.perlmonks.org?node_id=985882

Mulga has asked for the wisdom of the Perl Monks concerning the following question:

I am running Perl on OS X. The version of Perl is 5.12.4, Apache is 2.2.1, MySql is 5.5.27

I am having a problem running using Apache with the CGI and mysqlPP modules.

I can run the following code natively without issue.

#!usr/bin/perl -w use strict; use DBI; use CGI qw(:standard); my $dbh = DBI->connect("dbi:mysqlPP:database=menagerie:host=localhost" +, uid, pwd, {'RaiseError' => 1}); print header(), start_html("Good Return - Constituent Report"), h1("Good Return - Constituent Report"); print p("Does this work?"); print p("Databases"); print p("========="); print end_html;

However when I try and run it in a browser, as intended, it fails. The following is output from the apache log. You can see that it is unable to find mysqlPP but when I look in PPM I can see that it is inatlled and I can run it natively, i.e. not as CGI.

Any help would be greatly appreciated.

========== Apache Log Start ==========</p> Perhaps the DBD::mysqlPP perl module hasn't been fully installed, or perhaps the capitalisation of 'mysqlPP' isn't right. Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge. at /Users/paul_griffin/Sites/testsite/html01.pl line 41 install_driver(mysqlPP) failed: Can't locate DBD/mysqlPP.pm in @INC (@ +INC contains: /LibraryPerl/5.12/darwin-thread-multi-2level /Library/P +erl/5.12 /Network/Library/Perl/5.12/darwin-<p>thread-</p>multi-2level + /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.3 /System/Libr +ary</p>/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.1 +2 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System +/Library/Perl/Extras/5.12 .) at (eval 5) line 3. Perhaps the DBD::mysqlPP perl module hasn't been fully installed, or perhaps the capitalisation of 'mysqlPP' isn't right. Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge. at /Users/paul_griffin/Sites/testsite/htmltest.pl line 13 Premature end of script headers: htmltest.pl

Replies are listed 'Best First'.
Re: Problems with mysqlPP and Apache
by Anonymous Monk on Aug 07, 2012 at 07:50 UTC

    Well, if it isn't installed in the @INC that is reported in your apache log, where is it installed?

    perl -MData::Dumper -MDBD::mysqlPP -le " print Dumper( \%INC, \@INC ) "

Re: Problems with mysqlPP and Apache
by thonar (Monk) on Aug 08, 2012 at 11:19 UTC

    open a terminal and type:

    perl -le 'print for @INC'

    you should see all directorys in @INC. Now try this with the apache user, there for type:

    su - su - YOUR_APACHE_USER_NAME -c "perl -le 'print for @INC'"

    there should be some slide differences bettween them and this should be the reason for your problem.

    Try this in a new terminal:

    perl -MData::Dumper -MDBD::mysqlPP -le " print Dumper( \%INC ) " | grep "DBD/mysqlPP"

    now you can add the shown directory in your script like this:

    ... use lib qw( DIRECTORY_PATH ); use DBI; use CGI qw(:standard); ...

    sure not the best way to do this, but it should be work out.