4 Replies Latest reply: Feb 21, 2013 1:31 PM by cj RSS

    Problem with env vars (ORACLE_HOME and LD_LIBRARY_PATH) in Linux server

    943072
      Hello all.

      Let me introduce my problem with Oracle connection.


      I currently have a Red Hat Enterprise Linux Server release 5.5.
      This server is running php and will connect to a Unix server where Oracle DB is located.

      After a lot of effort, including even altering selinux configuration, I achieved installing Oci8 extension in php (version 5.1.6) in Redhat server, but when executing a simple php test (including just oci_connect function), I get the following error:

      "Warning: oci_connect() [function.oci-connect]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and LD_LIBRARY_PATH are set and point to the right directories in /var/www/html/testoracle.php on line 6
      not connected"




      I have checked the values of ORACLE_HOME and LD_LIBRARY_PATH with a script containing phpinfo() function, and I confirmed that their values are correctly set in:
      Apache Environment, oci8, Environment and PHP Variables tables.

      Their values are /opt/oracle/oraclehome and /opt/oracle/oraclehome/lib respectively.
      /opt/oracle/oraclehome is the folder where I had Oracle Client 10.2 installed.

      I have also checked the oracle.conf file in /etc/ld.so.conf/ folder, and it point to /opt/oracle/oraclehome/lib too.

      I have added user 'apache' to group 'oracle'.

      I had Apache restarted, even the server restarted, but even now I keep getting the same error about Environment Variables.


      Is there any ideas about what I could do to fix it?


      Thank you in advance.
        • 1. Re: Problem with env vars (ORACLE_HOME and LD_LIBRARY_PATH) in Linux server
          943072
          Some additional info about env vars settings in my system:





          - I have set values for these Env Vars in .bash_profile files

          ORACLE_HOME=/opt/oracle/oraclehome export ORACLE_HOME
          LD_LIBRARY_PATH=/opt/oracle/oraclehome/lib export LD_LIBRARY_PATH

          these lines have been added to files

          /root/.bash_profile
          /home/oracle/.bash_profile
          /opt/pmx/home/.bash_profile
          /etc/skel/.bash_profile




          - I have also set values in .bashrc files

          export ORACLE_HOME=/opt/oracle/oraclehome
          export LD_LIBRARY_PATH=/opt/oracle/oraclehome/lib

          in the following files

          /root/.bashrc
          /home/oracle/.bashrc
          /etc/skel/.bashrc





          - in /etc/profile file, I had the following lines added


          ORACLE_BASE=/opt/oracle
          ORACLE_SID=
          ORACLE_TERM=xterm;
          ORACLE_HOME=/opt/oracle/oraclehome
          LD_LIBRARY_PATH=$ORACLE_HOME/lib
          NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
          PATH=$PATH:$ORACLE_HOME/bin:$LD_LIBRARY_PATH
          CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; TMPDIR=/var/tmp
          TNS_ADMIN=/opt/oracle/oraclehome/network/admin




          - in /opt/pmx/apache-2.2.8/bin/envvars :

          ORACLE_BASE=/opt/oracle
          ORACLE_SID=
          ORACLE_TERM=xterm
          ORACLE_HOME=/opt/oracle/oraclehome
          LD_LIBRARY_PATH=$ORACLE_HOME/lib
          NLS_LANG = AMERICAN_AMERICA.UTF8
          PATH=$PATH:$ORACLE_HOME/bin:$LD_LIBRARY_PATH
          CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; TMPDIR=/var/tmp
          TNS_ADMIN=/opt/oracle/oraclehome/network/admin

          export ORACLE_BASE
          export ORACLE_SID
          export ORACLE_TERM
          export ORACLE_HOME
          export LD_LIBRARY_PATH
          export NLS_LANG
          export PATH
          export CLASSPATH
          export TNS_ADMIN



          - and finally in /etc/httpd/conf/httpd.conf :

          SetEnv ORACLE_HOME               /opt/oracle/oraclehome
          SetEnv LD_LIBRARY_PATH          /opt/oracle/oraclehome/lib
          LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so


          Also, I have changed permissions in lib folder:
          #chmod o+x /opt/oracle/oraclehome/lib
          #chmod o+x /opt/oracle/oraclehome
          #chmod o+x /opt/oracle
          #chmod o+x /opt



          I have read about a 'changePerm.sh' script that could get the whole permissions issue done, but there is no such file in my server.

          Edited by: 940069 on Jun 12, 2012 4:06 AM

          Edited by: 940069 on Jun 12, 2012 4:08 AM
          • 2. Re: Problem with env vars (ORACLE_HOME and LD_LIBRARY_PATH) in Linux server
            943072
            Problem solved

            I had to uninstall Oracle Instant Client, which created a conflict with Oracle Client.
            • 3. Re: Problem with env vars (ORACLE_HOME and LD_LIBRARY_PATH) in Linux server
              992584
              my solution was:

              add user that startup apache (daemon) in group dba and oinstall.

              problem solved.

              regards.
              • 4. Re: Problem with env vars (ORACLE_HOME and LD_LIBRARY_PATH) in Linux server
                cj
                Solution to what? Adding those groups to apache is a big security issue because any user who can compromise your apache stack can overwrite your Oracle installation.