Forum Stats

  • 3,876,199 Users
  • 2,267,081 Discussions
  • 7,912,467 Comments

Discussions

OCIEnvNlsCreate() failed. There is something wrong with your system - please check that LD_LIBRARY_P

daniel4996
daniel4996 Member Posts: 3
edited Sep 20, 2017 11:28PM in PHP

Hi,

I've been having troubles with OCI8.

My environment description is the following:

Red Hat Enterprise Linux Server release 7.4 (Maipo) (x86_64)

PHP 5.4.16

Apache/2.4.6 (Red Hat Enterprise Linux)

Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit

I installed from: Instant Client downloads for Linux x86-64

- oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm

oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm

-   oracle-instantclient12.2-odbc-12.2.0.1.0-1.x86_64.rpm

Also, I install OCI8 1.4.10, following the next steps:

cd /installation

tar -zxf oci8-1.4.10.tgz

cd oci8-1.4.10

phpize

./configure -with-oci8=shared,instantclient,/usr/lib/oracle/12.2/client64/lib

make install

I edited php.ini with:

extension = oci8.so

...

..

..

extension_dir=/usr/lib64/php/modules

I made a phpinfo page:

pastedImage_2.png

Environment variable are defined in:

/root/.bash_profile :

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

export ORACLE_HOME=/usr/lib/oracle/12.2/client64

export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib

export NLS_LANG=American_America.UTF8

export TNS_ADMIN=$ORACLE_HOME/network/admin

PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

export PATH

and in /etc/sysconfig/httpd

LANG=C

LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib

Whe I try to run this test code in php:

<?php

$Conection = oci_connect('user','pass','IP/name');

if(!$Conection){

$e=oci_error();

echo"Error:".$e["message"];

die();

}

$sqlc="select * from customers";

    $Show=oci_parse($Conection, $sqlc);

        if (!$Show){

        $e=oci_error($Conection);

        echo "Request error".$e["message"];

        die();

    }  

    $r=oci_execute($Show);

while($row=oci_fetch_array($Show,OCI_ASSOC)){

        $n= $row['CUSTOMER_NAME'];

        $c= $row['CITY'];

        echo $n;

        echo "<br>";

        echo $c;

}

?>

and use this:

cd /var/log/httpd

tail -F error_logs

I got this:

[Fri Sep 15 11:42:39.804547 2017] [:error] [pid 1278] [client 172.24.143.153:50931] PHP Warning:  oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that LD_LIBRARY_PATH includes the directory with Oracle Instant Client libraries in /var/www/html/prueba_oracle.php on line 5

[Fri Sep 15 11:42:39.804679 2017] [:error] [pid 1278] [client 172.24.143.153:50931] PHP Warning:  oci_connect(): Error while trying to retrieve text for error ORA-01804\n in /var/www/html/prueba_oracle.php on line 5

I thought that the LD_LIBRARY_PATH was not set, but when I did "echo $LD_LIBRARY_PATH", I got /usr/lib/oracle/12.2/client64/lib

phpinfo shows me:

pastedImage_10.png

pastedImage_11.png

pastedImage_13.png

pastedImage_14.png

The second error, I read that it was an error with time zone but I don't know how to set the correct value

Maybe the problem is the NLS_LANG.

Thanks for reading

Any help would be appreciated.

Tagged:

Answers

  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,656 Employee
    edited Sep 15, 2017 6:20PM

    Thanks for the detail

    - do you have other Oracle software on this machine?

    - since you're using Instant Client, make sure ORACLE_HOME is not set

    - you don't need to set TNS_ADMIN in your case: just create the directory /usr/lib/oracle/12.2/client64/lib/network/admin if you want to put config files with Instant Client

    - all (necessary) Oracle environment variables in your shell should also be set in /etc/sysconfig/httpd  E.g. NLS_LANG

    - Check all the Oracle files are readable by the PHP process (this shouldn't be a problem, but ...)

    - If you're using PHP OCI8 do you really need the odbc Instant Client package?

  • daniel4996
    daniel4996 Member Posts: 3
    edited Sep 18, 2017 2:10PM

    Hi! Thanks for answering

    - No, I don't

    - I don't understand. Should I erase "export ORACLE_HOME=/usr/lib/oracle/12.2/client64" line in .bash_profile and in /etc/sysconfig/httpd  ?

    - Done

    - Should I use the "export" word?

    - How can I do that?

    - I got confused, I actually installed " oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm" instead of  "oracle-instantclient12.2-odbc-12.2.0.1.0-1.x86_64.rpm"

    Thanks!

  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,656 Employee
    edited Sep 20, 2017 11:28PM

    Don't set ORACLE_HOME

    Don't use 'export' in /etc/sysconfig/httpd in that version of Linux (it was needed in older versions).  This file is not a shell script.

    Your /etc/sysconfig/httpd should look like:

    LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib

    NLS_LANG=American_America.UTF8

    You can optionally set TNS_ADMIN, if you need it.  But use an absolute path (starting with a '/') and do not use variables on the right hand side of the '='.

    Your .bashrc will need to use 'export':

    export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib

    export NLS_LANG=American_America.UTF8

    export PATH=$PATH:$HOME/bin:/usr/lib/oracle/12.2/client64/bin

This discussion has been closed.