Re: Error appears in web log but script runs ok on the command line

Bruce Johnson <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <[email protected]>
Oh it turned out to be even simpler than that, and for once it wasn't MY fat fingers that fat fingered it this time :-)

At first, it wasn't working because the SetEnv variable was not set in the virtual host  conf files, just in the main httpd.conf .

Then I didn't check closely enough when the person doing the work said he'd copied those to the conf where the virtual host definitions were set. 

Working system httpd.conf:

 grep LD_LIB /etc/httpd/conf/httpd.conf 
SetEnv LD_LIBRARY_PATH /usr/lib/oracle/11.2/client64/lib

Broken system httpd.conf:

grep LD_LIB /etc/httpd/conf/httpd.conf 
#SetEnv LD_LIBRARY_PATH /usr/lib/oracle/12.1/client64/lib

Broken system ssl.conf:

grep LD_LIB /etc/httpd/conf.d/ssl.conf 
SetEnv LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
SetEnv LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib

Oops. 

Thanks for your help and suggestions, and Carl, who was right all along! 

On Oct 20, 2013, at 5:53 AM, lesleyb <[email protected]> wrote:

> Hi Bruce
> 
> On Fri, Oct 18, 2013 at 07:56:52PM +0000, Bruce Johnson wrote:
>> First thing I checked, and they're set correctly;
>> 
>>> From %ENV on the broken system:
>> 
>> 
>> ORACLE_HOME --> /usr/lib/oracle/12.1/client64
>> LD_LIBRARY_PATH --> /usr/lib/oracle/12.1/client64/lib
>> 
> but the original error is 
> Can't load '/usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so'
> The error under the web server environment is saying Oracle.so is not in
> /usr/local/lib64/perl5/auto/DBD/Oracle which is where it is looking for it.
> 
> I'm assuming Oracle.so is installed on your system somewhere because the script
> works on the command line but not from within Apache.
> 
> Perhaps check and compare the %ENV in Apache with the command-line %ENV? And
> note Apache is looking for the /usr/local/lib64 directory - not anything in
> /usr/lib or /usr/lib64.
> 
> Kind regards
> 
> Lesley
>> 
>> This is the only thing I can think of that could cause this error. I've compared permissions, etc with a working server and I see nothing wrong. The only main difference is that the problem system is running version 12 of the Instant Client and the working one is running 11.2, but that would cause the program to fail on the command line as well.
>> 
>> On Oct 18, 2013, at 12:30 PM, "Furst, Carl" <[email protected]>
>> wrote:
>> 
>>> Ld_library_path is getting set in apache configs or wrapper scripts?
>>> 
>>> Have you tried setting
>>> SetEnv LD_LIBRARY_PATH
>>> 
>>> In httpd.conf? 
>>> 
>>> Or have it set when you call apachectl??
>>> 
>>> 
>>> 
>>> Carl Furst
>>> 
>>> 
>>> 
>>> 
>>> On 10/18/13 3:10 PM, "Bruce Johnson" <[email protected]> wrote:
>>> 
>>>> I'm getting the following error on a newly set-up server:
>>>> 
>>>> [Fri Oct 18 12:02:06 2013] [error] install_driver(Oracle) failed: Can't
>>>> load '/usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so' for module
>>>> DBD::Oracle: libocci.so.12.1: cannot open shared object file: No such
>>>> file or directory at /usr/lib64/perl5/DynaLoader.pm line 200.\n at (eval
>>>> 11) line 3\nCompilation failed in require at (eval 11) line 3.\nPerhaps a
>>>> required shared library or dll isn't installed where expected\n at
>>>> /home/webfiles/apply/perl/oratest.pl line 7\n
>>>> 
>>>> 
>>>> It's a really simple script that just connects to the database:
>>>> 
>>>> #!/usr/bin/perl
>>>> use DBI;
>>>> use strict;
>>>> my $login="xxxxxx";
>>>> my $dbpass='xxxxxx';
>>>> my $dbname="host=xxxxx.xxxx.xxxxx.xxxx;sid=xxxxxx";
>>>> my $lda = DBI->connect("dbi:Oracle:$dbname", $login, $dbpass, {RaiseError
>>>> =>1});
>>>> print "Content-type: text/html\n\n";
>>>> print "It Works";
>>>> exit;
>>>> 
>>>> 
>>>> I've confirmed that Apache has the correct LD_LIBRARY_PATH and
>>>> ORACLE_HOME vars set yet whenever we run the script on the web server we
>>>> get the error. 
>>>> 
>>>> On the command line it's:
>>>> 
>>>> [root@xxxx perl]# perl oratest.pl
>>>> Content-type: text/html
>>>> 
>>>> It Works
>>>> 
>>>> 
>>>> Any ideas?
>>>> 
>>>> -- 
>>>> Bruce Johnson
>>>> University of Arizona
>>>> College of Pharmacy
>>>> Information Technology Group
>>>> 
>>>> Institutions do not have opinions, merely customs
>>>> 
>>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> **********************************************************
>>> 
>>> MLB.com: Where Baseball is Always On
>> 
>> -- 
>> Bruce Johnson
>> University of Arizona
>> College of Pharmacy
>> Information Technology Group
>> 
>> Institutions do not have opinions, merely customs
>> 
>> 

-- 
Bruce Johnson

"Wherever you go, there you are." B. Banzai, PhD
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.