http://qs321.pair.com?node_id=1223994

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

I am installing DBD::Oracle. After compiling and installing only root user is able to use it. For all other user I am getting install_driver(Oracle) failed: Can't locate Oracle.pm in @INC

Red Hat Enterprise Linux Server release 7.5 (Maipo)

Oracle client 11gR2

which perl /usr/bin/perl

perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi (with 33 registered patches, see perl -V for more detail) Copyright 1987-2012, Larry Wall

perl -V output from root Built under linux Compiled at Mar 2 2017 08:50:35 %ENV: PERL5LIB="/root/perl5/lib/perl5:" PERL_LOCAL_LIB_ROOT=":/root/perl5" PERL_MB_OPT="--install_base /root/perl5" PERL_MM_OPT="INSTALL_BASE=/root/perl5" @INC: /root/perl5/lib/perl5/5.16.3/x86_64-linux-thread-multi /root/perl5/lib/perl5/5.16.3 /root/perl5/lib/perl5/x86_64-linux-thread-multi /root/perl5/lib/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5

For all all other users Built under linux Compiled at Mar 2 2017 08:50:35 @INC: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5

Replies are listed 'Best First'.
Re: DBD::Oracle installs under root only
by Corion (Patriarch) on Oct 14, 2018 at 08:31 UTC

    This is because you have set up your root user environment to install Perl modules only for that user:

    PERL5LIB="/root/perl5/lib/perl5:" PERL_LOCAL_LIB_ROOT=":/root/perl5" PERL_MB_OPT="--install_base /root/perl5" PERL_MM_OPT="INSTALL_BASE=/root/perl5"

    Remove these settings and root will install modules for all users.

      Thanks a lot for your input. I have unset those variables, recompiled the DBD and installed it again. Now working fine for all users through cli. I am getting the following error when I am executing the same code through Apache web server cgi-bin:

      AH01215: install_driver(Oracle) failed: Can't load '/usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file: No such file or directory at /usr/lib64/perl5/DynaLoader.pm line 190.

      httpd -v Server version: Apache/2.4.6 (Red Hat Enterprise Linux) Server built: May 28 2018 16:19:32

      uname -a Linux ess.saildsp.co.in 3.10.0-862.14.4.el7.x86_64 #1 SMP Fri Sep 21 09:07:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

      Oracle client 11gR2 I have set ORACLE_HOME and LD_LIBRARY_PATH in /etc/sysconfig/httpd I have also set LD_LIBRARY_PATH in /etc/ld.so.conf and executed ldconfig Pl. help

        The next step is to look where libclntsh.so.11.1 exists and to check if LD_LIBRARY_PATH includes that directory.

        Then, check whether the user(s) trying to use DBD::Oracle have read permission on the file and all directories upward of libclntsh.so.11.1.

        Back in the day, I had to run Perl code that was using DBD::Oracle on many UNIX platforms, Linux included. Running ldconfig should have done it, did you make sure and restart Apache after you ran ldconfig? The running web server won't have the new settings until you do that.

        If that doesn't do it, then what you might want to do is to add an explicit SetEnv in your httpd.conf - I remember having to do this too. See mod_env describing SetEnv for Apache 2.4.