1 (edited by r.remya1 2021-04-09 08:45:58)

Topic: oci_connect(): OCIEnvNlsCreate() failed

Hi
I have installed php 8.3, oracle client 19.3. OCI8 module ie enabled and when checked if OCI_CONNECT() exists it is true.
But on trying to connect it throws error :
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
oci_connect(): Error while trying to retrieve text for error ORA-01804 in

Am missing the environment variables LD_LIBRARY_PATH,  ORACLE_HOME,TNS_ADMIN in the phpinfo() page.
Tried setting in etc->sysconfig->httpd but it is not reflecting.
Tried setting using systemctl edit php-fpm
[Service]
Environment=LD_LIBRARY_PATH=/opt/ora/19c/client/lib
Environment=ORACLE_HOME=/opt/ora/19c/client
Environment=TNS_ADMIN=/opt/ora/19c/client/network/admin

I dont know if this is a problem but on running the command ldconfig --- ldconfig: /opt/ora/19c/client/lib/libexpat.so.1 is not a symbolic link

Still not working.. Where I have to set these variables so that php or apache can utilize it.

Re: oci_connect(): OCIEnvNlsCreate() failed

Have you see https://blog.remirepo.net/post/2020/05/ … ns-for-PHP  ?

Desktop: Fedora 33 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 34 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: oci_connect(): OCIEnvNlsCreate() failed

Yes I followed the same post but no luck

Re: oci_connect(): OCIEnvNlsCreate() failed

I don't have any libexpat in my oracle directory

Please try with official oracle instantclient RPM, which gives good result

P.S. or, at least using way describe in § 5.1

Desktop: Fedora 33 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 34 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: oci_connect(): OCIEnvNlsCreate() failed

Also knowing about used distro may help

And FYI current build use version 19.6, next will use 21.1
https://github.com/remicollet/remirepo/issues/167

Also

$ php --ri oci8

Also a test from command line (to exclude web env specific issues)

Desktop: Fedora 33 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 34 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: oci_connect(): OCIEnvNlsCreate() failed

$ php --ri oci8

oci8

OCI8 Support => enabled
OCI8 DTrace Support => enabled
OCI8 Version => 3.0.1
Oracle Run-time Client Library Version => 19.3.0.0.0
Oracle Compile-time Instant Client Version => 19.9

Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off

Statistics =>
Active Persistent Connections => 0
Active Connections => 0
This is what I get on running the oci8 command and on running printenv I have :

LD_LIBRARY_PATH=/opt/ora/19c/client
MODULES_RUN_QUARANTINE=LD_LIBRARY_PATH LD_PRELOAD
LANG=en_US.UTF-8
ORACLE_HOME=/opt/ora/19c/client
SELINUX_ROLE_REQUESTED=
PWD=/home/ec2-user
HOME=/home/ec2-user

SELINUX_LEVEL_REQUESTED=
LOADEDMODULES=
SSH_TTY=/dev/pts/0
MAIL=/var/spool/mail/ec2-user
TERM=xterm
SHELL=/bin/bash
TNS_ADMIN=/opt/ora/19c/client/network/admin
SELINUX_USE_CURRENT_RANGE=

Re: oci_connect(): OCIEnvNlsCreate() failed

Try oci_connect from command line, something like (with proper credentials)

php -r 'var_dump(oci_connect("xxx", "yyy", "..."));'

Desktop: Fedora 33 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 34 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: oci_connect(): OCIEnvNlsCreate() failed

This is what I get....
php -r 'var_dump(oci_connect("xxx", "yyy", "..."));'
resource(4) of type (oci8 connection)

Re: oci_connect(): OCIEnvNlsCreate() failed

Which means that connection works from CLI
So this is only a web-server issue.

so (again)
- which distro
- try with oracle instant client RPM
- try solution in § 5.1

Desktop: Fedora 33 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 34 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: oci_connect(): OCIEnvNlsCreate() failed

Also try "clear_env = no" in FPM pool configuration

Desktop: Fedora 33 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 34 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi