Thank you Luis

I am setting in place an Apache Web server and I want to get access to a remote Oracle 8 database.

Here are the step I did

1) I set up Linux RedHat 7.3 (Kernel 2.4.18-3
2) I updated OS through RHN (Kernel 2.4.18-17.7.x)
3) I installed Oracle Client 8.1.5 for Linux in /home/oracle (user:oracle, group: oracle)
4) I Installed Apache 2.0.43 and configure the httpd.conf file with my oracle env variables in the virtual host directive
************************************************************************************************
<VirtualHost 172.16.1.32>
ServerAdmin [EMAIL PROTECTED]
DocumentRoot /var/www/erpdocs
ServerName dev_erp.beijing.rougemont.com
SetEnv ORACLE_HOME /home/oracle
SetEnv ORACLE_SID beijing
SetEnv ORACLE_USERID system/system@beijing
SetEnv LD_LIBRARY_PATH /home/oracle/lib
SetEnv QTDIR /usr/lib/qt3-gcc2.96
LogLevel warn
ErrorLog logs/erp_error
CustomLog logs/erp_access common
</VirtualHost>
************************************************************************************************

5) I Installed Perl 5.8.0 and here is the output of the perl -V command:
************************************************************************************************
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.18-17.7.x, archname=i686-linux-thread-multi
uname='linux develop 2.4.18-17.7.x #1 tue oct 8 11:49:30 edt 2002 i686 unknown '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.3 2.96-112)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldl -lm -lpthread -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
libc=/lib/libc-2.2.5.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.2.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
Built under linux
Compiled at Nov 7 2002 08:45:28
@INC:
/usr/local/lib/perl5/5.8.0/i686-linux-thread-multi
/usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl

************************************************************************************************

6) I updated CPAN (v.1.63)
7) I installed DBI from cpan and run the test successfully
8) I Installed DBD::Oracle from cpan and run test successfully
9) I ran tests (DBI and DBD) successfully with perl command as root
10) I wrote down a little perl to connect Database, select a row and print a field
************************************************************************************************
1- #!/usr/local/bin/perl
2- BEGIN {
3- $ENV{'ORACLE_HOME'} = "/home/oracle";
4- $ENV{'ORACLE_SID'} = "beijing";
5- $ENV{'LD_LIBRARY_PATH'} = "/home/oracle/lib";
6- $ENV{'NLS_LANG'} = "AMERICAN_AMERICA.WE8ISO8859P1";
7- }
8- use strict;
9- use warnings;
10- use CGI qw(:all);
11- use DBI;
12- sub dbi_error
13- {
14- my $msg = shift;
15- print "<p>$msg\n</p><br>";
16- die $msg;
17- }
18- my $dbh = DBI->connect("dbi:Oracle:Beijing","oasis42","info02") || &dbi_error("$DBI::errstr");
19- print "Connected to Oracle\n";
20- my $sql="select count(*) FROM emp_pass where lower(priv) like \'%erp%\'and badge_no= 1016 and pass=\'armand\'";
21- print "SQL: $sql\n";
22- my $sth=$dbh->prepare($sql) || &dbi_error("$DBI::errstr");
23- $sth->execute() || &dbi_error("$DBI::errstr");
24- my $ok=$sth->fetchrow_array;
25- if ($ok)
26- {
27- print "Get the record\n";
28- }
29- $sth->finish();
30- $dbh->disconnect();
31- exit;

****************************************************************************************************

11) I logged as root and run script from command line [perl ora_check.pl] and everything run fine
12) I logged as oracle and run script from command line [perl ora_check.pl] and everything run fine
13) I copy .bashrc and .bash_profile from oracle user to apache user
14) I logged as apache and run script from command line. Here is the output of the script when run as apache user not yet with HTTPD
************************************************************************************************
install_driver(Oracle) failed: Can't load '/usr/local/lib/perl5/site_perl/5.8.0/i686-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/local/lib/perl5/5.8.0/i686-linux-thread-multi/DynaLoader.pm line 229.
at (eval 1) line 3
Compilation failed in require at (eval 1) line 3.
Perhaps a required shared library or dll isn't installed where expected
at ./ora_check.pl line 18

************************************************************************************************

15) Did i missed something????? why does it work when run as root or oracle but not as Apache ?
16) I have the same messages while running this perl script from APACHE web server
17) Did i need to change some parameter for the compiler when I compile perl 5.8.0?




Thank you for helping me

Luis Garcia wrote:

If you have enviroment variables problem?. try to run ".profile" at the
begining of your script (if you are using UNIX) or try to insert them at the
beginin of your script.

example in Perl:
$ENV{"ORACLE_HOME"} = "/ora/ora01/app/oracle/product";
$ENV{"ORA_NLS33"} =
"/ora/ora01/app/oracle/product/ocommon/nls/admin/data";
$ENV{"LD_LIBRARY_PATH"} = "/ora/ora01/app/oracle/product/lib";
$ENV{"ORAENV_ASK"} = "NO";
$ENV{"ORACLE_BASE"} = "/ora/ora01/app/oracle";
$ENV{"ORACLE_SID"} = "dbnet2";
$ENV{"TWO_TASK"} = "dbnet2";
$ENV{"ORACLE_OWNER"} = "oracle";

-----Original Message-----
From: Michael A Chase [mailto:mchase@;ix.netcom.com]
Sent: Wednesday, November 06, 2002 1:12 AM
To: dbi-users; Armand Brisson
Subject: Re: Script Running well as Root user but not as Apache user ?


On Wed, 06 Nov 2002 14:19:18 +0800 Armand Brisson
<[EMAIL PROTECTED]> wrote:


I already have set httpd.conf with the environment variable.

Problem occurs even if i just run the script as apache or other users
work only in root or oracle users

Michael A Chase wrote:


http://xmlproj.com/fom-serve/cache/20.html
http://xmlproj.com/fom-serve/cache/5.html
http://xmlproj.com/fom-serve/cache/96.html

Setting LD_LIBRARY_PATH after perl has started probably has no effect. It needs to be set in the webserver's environment.

Then check the file permissions in $ORACLE_HOME/lib and those of the DBI
and DBD::Oracle files.

The URIs above point to a lot of things that should be checked, not just
environment variables, though those are the most common problem.

A comparison of the environment variables set for root, oracle, and a user
that fails might be useful as well.

Please keep this on list, I am not the sole source of all wisdom.




Reply via email to