Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.3K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 545 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 440 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
OCIEnvNlsCreate() failed. There is something wrong with your system - please check that LD_LIBRARY_P

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:
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:
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.
Answers
-
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?
-
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!
-
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