Re: Apache, Oracle, Perl DBI Problems

From: Hardy Merrill (hmerrill_at_redhat.com)
Date: 12/12/03


Date: Fri, 12 Dec 2003 15:39:35 -0500
To: Kevin Moore <kmoore@esntech.com>

I'm taxing my memory to try to remember how we did this a few
years ago - so take this with a grain of salt. One thing you
should know if you don't already is there are probably several
ways to fix your problem - this is just one. In fact Tim
Bunce suggested setting LD_LIBRARY_PATH in the apache
configuration - I don't know how to do that.

I believe at the start of every perl cgi script interfacing
with Oracle we did this:

#!/usr/bin/perl -w

BEGIN {
   export ORACLE_HOME=/path/to/oracle/home
   export ORACLE_SID=abc # substitute your sid for 'abc'
   export LD_LIBRARY_PATH=/blah/blah
}

use strict "subs";
use Apache::DBI;
use DBI;
#etc.
--------------------------------------
and, we did this - in /etc/ld.so.conf, add a line like
this

  /path/to/oracle/home/lib

and then run 'ldconfig'.

That's as much as I can remember - hope it helps.

I'd also try searching on google for something like
'perl dbi oracle'.

-- 
Hardy Merrill
Red Hat, Inc.
Kevin Moore [kmoore@esntech.com] wrote:
> All:
> 
> Thanks all for your replies. I'm still unable to make this work. Is 
> there a "How To" doc for configuring Apache 2.x to run perl scripts 
> somewhere I can review to find out where my install went bad? I've not 
> found anything out there like this and am floundering. Thanks.
> 
> Kevin
> 
> Tim Bunce wrote:
> 
> >On Thu, Dec 11, 2003 at 08:29:14PM -0800, Kevin Moore wrote:
> > 
> >
> >>>Hi Steve,
> >>>
> >>>I can run the scripts from the command line. The script connects to 
> >>>the database with no questions asked and selects data from tables. I'm 
> >>>pretty sure the problem is with Apache interfacing with Perl/DBI. My 
> >>>problem is knowing what to do to fix this. Should environments such as 
> >>>LD_LIBRARY_PATH be set in the Apache configuration or what?
> >>>     
> >>>
> >
> >Yes.
> >
> >Tim.
> >
> > 
> >
> >>I'm new to 
> >>   
> >>
> >>>this area as you can tell. I'm looking for somebody who has made this 
> >>>work to point me in the right direction. Any pointers are appreciated. 
> >>>Thanks.
> >>>
> >>>Kevin
> >>>     
> >>>
> >>
> >>Steve Baldwin wrote:
> >>
> >>   
> >>
> >>>Did you try executing your Perl CGI script from the command line (as
> >>>opposed to via the web server) ?  None of our CGI scripts set
> >>>LD_LIBRARY_PATH, (although we use Apache 1 not 2).  Could it be a
> >>>permissions thing ?  Did you confirm that the Oracle client library is
> >>>present and accessible ?  If the cgi executes from the command line,
> >>>maybe it's an Apache setup thing rather than a DBI thing.
> >>>
> >>>-----Original Message-----
> >>>From: Kevin Moore [mailto:kmoore@esntech.com] 
> >>>Sent: Friday, 12 December 2003 11:12 AM
> >>>To: 'dbi-users@perl.org'
> >>>Subject: Apache, Oracle, Perl DBI Problems
> >>>
> >>>
> >>>Gang,
> >>>
> >>>I'm attempting to write a perl script, callable from a URL, that 
> >>>connects me to an Oracle 9i database. I've combed the help pages and 
> >>>think i'm just missing something simple. From what i've read it appears 
> >>>that my LD_LIBRARY_PATH is not being set correctly. I've set the 
> >>>LD_LIBRARY_PATH variable in the perl script and installed the DBI 
> >>>modules. Below is the environment, code snippet, and error message. Any 
> >>>ideas anyone? Completely lost here. - Kevin
> >>>
> >>>Environment:
> >>>
> >>>Red Hat Linux 9.0
> >>>Apache 2.0.40
> >>>Apache-DBI-0.91
> >>>DBD-Oracle-1.14
> >>>DBI-1.35
> >>>
> >>>Code Snippet:
> >>>
> >>>#!/usr/bin/perl -w
> >>>
> >>>use strict "subs";
> >>>use Apache::DBI;
> >>>use DBI;
> >>>use DBD::Oracle;
> >>>use CGI;
> >>>use CGI::Carp qw(fatalsToBrowser);
> >>>use CGI::Cookie;
> >>>#use Apache::Registry;
> >>>
> >>>package CGIBook::Error;
> >>>
> >>>use vars qw( $dbh $CGI $TABLE $q $r @FIELD_NAMES);
> >>>
> >>>my ( $sth, @row );
> >>>
> >>>@FIELD_NAMES = ("uinp_uname", "uinp_fname", "uinp_lname", "uinp_active",
> >>>             "uinp_email", "uinp_passwd", "uinp_signup",
> >>>"last_login",
> >>>             "conf_passwd");
> >>>
> >>>$TABLE = "webusers";
> >>>$ENV{'ORACLE_HOME'} = '/home/oracle/product/9ias';
> >>>#$ENV{'LD_LIBRARY_PATH'} = '/home/oracle/product/9ias/lib';
> >>>$ENV{'TWO_TASK'} = 'webapp'; $ENV{'LD_RUN_PATH'} = 
> >>>"/home/oracle/product/9ias/lib:/home/oracle/product/9ias/r
> >>>dbms/lib";
> >>>
> >>>LD_LIBRARY_PATH = '/home/oracle/product/9ias/lib';
> >>>
> >>># $CGI = new CGI();
> >>>
> >>>### Connect To Database
> >>>
> >>>my $dbh = DBI->connect( "dbi:Oracle:WEBAPP.WORLD", "user", "password" ,
> >>>{
> >>>     PrintError => 0,
> >>>     RaiseError => 0
> >>>     } ) or die "Can't connect To Database: $DBI::errstr\n";
> >>>
> >>>Error message:
> >>>
> >>>[error] [client 192.168.1.3] Premature end of script headers: signup.cgi
> >>>[Thu Dec 11 16:01:14 2003] [error] [client 192.168.1.3] Can't load 
> >>>'/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/auto/DBD/Oracle/
> >>>Oracle.so' 
> >>>for module DBD::Oracle: libclntsh.so.8.0: cannot open shared object 
> >>>file: No such file or directory at 
> >>>/usr/lib/perl5/5.8.0/i386-linux-thread-multi/DynaLoader.pm line 229.
> >>>[Thu Dec 11 16:01:14 2003] [error] [client 192.168.1.3]  at 
> >>>/home/httpd/cgi-bin/signup.cgi line 6
> >>>[Thu Dec 11 16:01:14 2003] [error] [client 192.168.1.3] Compilation 
> >>>failed in require at /home/httpd/cgi-bin/signup.cgi line 6. [Thu Dec 11
> >>>16:01:14 2003] [error] [client 192.168.1.3] BEGIN 
> >>>failed--compilation aborted at /home/httpd/cgi-bin/signup.cgi line 6.


Relevant Pages

  • InterBase MEMO/BLOB fields, data with size > 1MB
    ... my Perl script I have a code part that fetches a data from database ... Scriptwork just fine if the "content" in MEMO or BLOB ... DBD-InterBase with some other Perl module? ... "The DBI currently defines no way to insert or update LONG/LOB values ...
    (perl.dbi.users)
  • RE: DBI problem
    ... I had Oracle 8 all along, I upgraded to ActiveState Perl 5.8.7 from ... DBD 1.16 and DBI 1.48. ... Did you install DBD::Oracle? ...
    (perl.dbi.users)
  • Re: install_driver(Oracle) failed: wrong ELF class: DynaLoader.pm
    ... I'm not the Oracle expert - treat what I say with a pinch of salt. ... So, if your Perl script sets LD_LIBRARY_PATH, ... Try modifying your cron job so that it runs a shell script which sets at ...
    (perl.dbi.users)
  • RE: Cant build DBD::Oracle on AIX 5.1 with Oracle 9.2
    ... Were you ever able to build a full 64-bit perl, DBI and DBD-ORACLE? ... Subject: Can't build DBD::Oracle on AIX 5.1 with Oracle 9.2 ... > Bjorn Naessens ...
    (perl.dbi.users)
  • RE: perl DBI oracle and error ORA 06502
    ... procedure, schema, some data and the exact perl code that calls it. ... I would also need the name of and version your OS, perl, DBI, ... DBD::Oracle, The Oracle client you are running and the Oracle DB ... The problem shows in the perl code. ...
    (perl.dbi.users)