You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jim Goh <gc...@yahoo.com> on 2006/12/13 16:52:18 UTC

[users@httpd] perl and mysql issue

Hi,
   
  I have perl 5.6.1 and mysql 5.0.24 installed and the following perl script works fine from command line, but not working when I run from the IE browser:
   
  #!/usr/local/bin/perl
  use DBI;
use CGI qw(:standard);
use CGI::Carp 'fatalsToBrowser';
use strict;
   
  print header;
print start_html;
  my $docID;
my $docfile = "test.doc";
my $docdesc = "this is test";
my $last_update;
my $dbh = DBI->connect("dbi:mysql:dbname", "username", "password" )
        or &dienice("Can't connect to database: $DBI::errstr");
  my $sth = $dbh->prepare("insert into test_tbl values(?,?,?,?)") or &dbdie;
$sth->execute($docID, $last_update, $docfile, $docdesc) or &dbdie;
  print end_html;

  and here is the error i got from browser after ran it:
   
  Software error:
install_driver(mysql) failed: Can't load '/usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/auto/DBD/mysql/mysql.so' for module DBD::mysql: ld.so.1: perl: fatal: libmysqlclient.so.15: open failed: No such file or directory at /usr/local/lib/perl5/5.6.1/sun4-solaris/DynaLoader.pm line 206.   at (eval 10) line 3  Compilation failed in require at (eval 10) line 3.  Perhaps a required shared library or dll isn't installed where expected   at /usr/local/apache2/cgi-bin/testdb.pl line 15  

Thanks all for your help!

 
---------------------------------
Any questions?  Get answers on any topic at Yahoo! Answers. Try it now.

Re: [users@httpd] perl and mysql issue

Posted by Issac Goldstand <ma...@beamartyr.net>.
You *could* use the SetEnv directive in httpd.conf to set Apache's
environment variables.  However, there's a better solution:

I'm not sure how it works on Solaris, but on Linux, you can edit the
file /etc/ld.so.conf and add /usr/local/mysql/lib/mysql to it.  Once
it's added run /sbin/ldconfig (optionally with -v to ensure that it
noticed the new directory) and it will know to look in
/usr/local/mysql/lib/mysql when it needs shared libraries.  This is the
more "correct" solution, I think.

  Issac

Jim Goh wrote:
> Issac,
>  
> Thanks for your quick reply.  This installation are all new in my server.
> I can run the script as any user as long as I set the LD_LIBRARY_PATH to
> /usr/local/mysql/lib/mysql path, w/o this LD set, i got same error as
> show up on the web site.
>  
> So I am not sure how to set the LD in the script?
>  
> My apache run with user nobody and group nobody.
>  
> thanks again!
> 
> */Issac Goldstand <ma...@beamartyr.net>/* wrote:
> 
>     It looks like your MySQL client library isn't installed properly, or
>     else require some special odd permissions.
> 
>     Did you recently change anything in your server MySQL setup?
>     Can you run the Perl script on the server as the same user Apache
>     runs as?
>     Finally, just to be absolutely sure - when you say it runs from the
>     "command" line, you *do* mean the command line on the Apache server,
>     right?
> 
>     Issac
> 
>     Jim Goh wrote:
>     > Hi,
>     >
>     > I have perl 5.6.1 and mysql 5.0.24 installed and the following perl
>     > script works fine from command line, but not working when I run
>     from the
>     > IE browser:
>     >
>     > #!/usr/local/bin/perl
>     > use DBI;
>     > use CGI qw(:standard);
>     > use CGI::Carp 'fatalsToBrowser';
>     > use strict;
>     >
>     > print header;
>     > print start_html;
>     > my $docID;
>     > my $docfile = "test.doc";
>     > my $docdesc = "this is test";
>     > my $last_update;
>     > my $dbh = DBI->connect("dbi:mysql:dbname", "username", "password" )
>     > or &dienice("Can't connect to database: $DBI::errstr");
>     > my $sth = $dbh->prepare("insert into test_tbl values(?,?,?,?)") or
>     &dbdie;
>     > $sth->execute($docID, $last_update, $docfile, $docdesc) or &dbdie;
>     > print end_html;
>     > and here is the error i got from browser after ran it:
>     >
>     >
>     >
>     > Software error:
>     >
>     > install_driver(mysql) failed: Can't load
>     '/usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/auto/DBD/mysql/mysql.so'
>     for module DBD::mysql: ld.so.1: perl: fatal: libmysqlclient.so.15:
>     open failed: No such file or directory at
>     /usr/local/lib/perl5/5.6.1/sun4-solaris/DynaLoader.pm line 206. at
>     (eval 10) line 3 Compilation failed in require at (eval 10) line 3.
>     Perhaps a required shared library or dll isn't installed where
>     expected at /usr/local/apache2/cgi-bin/testdb.pl line 15
>     >
>     > Thanks all for your help!
>     >
>     >
>     ------------------------------------------------------------------------
>     > Any questions? Get answers on any topic at Yahoo! Answers
>     > .
>     > Try it now.
> 
>     ---------------------------------------------------------------------
>     The official User-To-User support forum of the Apache HTTP Server
>     Project.
>     See for more info.
>     To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>     " from the digest: users-digest-unsubscribe@httpd.apache.org
>     For additional commands, e-mail: users-help@httpd.apache.org
> 
> 
> ------------------------------------------------------------------------
> Access over 1 million songs - Yahoo! Music Unlimited.
> <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/>
> 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] perl and mysql issue

Posted by Jim Goh <gc...@yahoo.com>.
Issac,
   
  Thanks for your quick reply.  This installation are all new in my server.
  I can run the script as any user as long as I set the LD_LIBRARY_PATH to /usr/local/mysql/lib/mysql path, w/o this LD set, i got same error as show up on the web site.
   
  So I am not sure how to set the LD in the script?
   
  My apache run with user nobody and group nobody.
   
  thanks again!

Issac Goldstand <ma...@beamartyr.net> wrote:
  It looks like your MySQL client library isn't installed properly, or
else require some special odd permissions.

Did you recently change anything in your server MySQL setup?
Can you run the Perl script on the server as the same user Apache runs as?
Finally, just to be absolutely sure - when you say it runs from the
"command" line, you *do* mean the command line on the Apache server, right?

Issac

Jim Goh wrote:
> Hi,
> 
> I have perl 5.6.1 and mysql 5.0.24 installed and the following perl
> script works fine from command line, but not working when I run from the
> IE browser:
> 
> #!/usr/local/bin/perl
> use DBI;
> use CGI qw(:standard);
> use CGI::Carp 'fatalsToBrowser';
> use strict;
> 
> print header;
> print start_html;
> my $docID;
> my $docfile = "test.doc";
> my $docdesc = "this is test";
> my $last_update;
> my $dbh = DBI->connect("dbi:mysql:dbname", "username", "password" )
> or &dienice("Can't connect to database: $DBI::errstr");
> my $sth = $dbh->prepare("insert into test_tbl values(?,?,?,?)") or &dbdie;
> $sth->execute($docID, $last_update, $docfile, $docdesc) or &dbdie;
> print end_html;
> and here is the error i got from browser after ran it:
> 
> 
> 
> Software error:
> 
> install_driver(mysql) failed: Can't load '/usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/auto/DBD/mysql/mysql.so' for module DBD::mysql: ld.so.1: perl: fatal: libmysqlclient.so.15: open failed: No such file or directory at /usr/local/lib/perl5/5.6.1/sun4-solaris/DynaLoader.pm line 206. at (eval 10) line 3 Compilation failed in require at (eval 10) line 3. Perhaps a required shared library or dll isn't installed where expected at /usr/local/apache2/cgi-bin/testdb.pl line 15 
> 
> Thanks all for your help!
> 
> ------------------------------------------------------------------------
> Any questions? Get answers on any topic at Yahoo! Answers
> .
> Try it now.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org



 
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.

Re: [users@httpd] perl and mysql issue

Posted by Issac Goldstand <ma...@beamartyr.net>.
It looks like your MySQL client library isn't installed properly, or
else require some special odd permissions.

Did you recently change anything in your server MySQL setup?
Can you run the Perl script on the server as the same user Apache runs as?
Finally, just to be absolutely sure - when you say it runs from the
"command" line, you *do* mean the command line on the Apache server, right?

  Issac

Jim Goh wrote:
> Hi,
>  
> I have perl 5.6.1 and mysql 5.0.24 installed and the following perl
> script works fine from command line, but not working when I run from the
> IE browser:
>  
> #!/usr/local/bin/perl
> use DBI;
> use CGI qw(:standard);
> use CGI::Carp 'fatalsToBrowser';
> use strict;
>  
> print header;
> print start_html;
> my $docID;
> my $docfile = "test.doc";
> my $docdesc = "this is test";
> my $last_update;
> my $dbh = DBI->connect("dbi:mysql:dbname", "username", "password" )
>         or &dienice("Can't connect to database: $DBI::errstr");
> my $sth = $dbh->prepare("insert into test_tbl values(?,?,?,?)") or &dbdie;
> $sth->execute($docID, $last_update, $docfile, $docdesc) or &dbdie;
> print end_html;
> and here is the error i got from browser after ran it:
>  
> 
> 
>   Software error:
> 
> install_driver(mysql) failed: Can't load '/usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/auto/DBD/mysql/mysql.so' for module DBD::mysql: ld.so.1: perl: fatal: libmysqlclient.so.15: open failed: No such file or directory at /usr/local/lib/perl5/5.6.1/sun4-solaris/DynaLoader.pm line 206.   at (eval 10) line 3  Compilation failed in require at (eval 10) line 3.  Perhaps a required shared library or dll isn't installed where expected   at /usr/local/apache2/cgi-bin/testdb.pl line 15  
> 
> Thanks all for your help!
> 
> ------------------------------------------------------------------------
> Any questions? Get answers on any topic at Yahoo! Answers
> <http://answers.yahoo.com/;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx>.
> Try it now.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org