77Vetter
77Vetter

Reputation: 269

Linux Oracle unix_odbc from PHP connection not working

I am running php v5 on RHEL using oracle client 19 (tnsnames.ora) I have odbcinst.ini and odbc.ini setup and is working from command prompt via:

isql -v myOdbc username pw

I had to specify LD_LIBRARY_PATH in order to get that to work. But now when I run test page in php and I try the odbc_connect command, it is giving me the following error: "Can't open lib '/var/opt/oracle/client2/lib/libsqora.so.19.1'" - which is the value that is in LD_LIBRARY_PATH

So it seems LD_LIBRARY_PATH isn't set correctly for Apache or PHP? If I do

php --info 

That returns: _SERVER["LD_LIBRARY_PATH"] => /var/opt/oracle/client2/lib so PHP "seems" to know the LD_LIBRARY_PATH but somehow Apache or something else doesn't?

Here is odbcinst.ini

[ODBC]
Trace=Yes
TraceFile=/tmp/sql.log
ForceTrace=No
Pooling=No
UsageCount=2

[Oracle_ODBC_Driver_in_ora19c]
Description=Oracle 19c ODBC driver.
Driver=/var/opt/oracle/client2/lib/libsqora.so.19.1
Setup=
FileUsage=
CPTimeout=
CPReuse=
UsageCount=2

Here is odbc.ini

[myOdbc]
Description     = wilson
Driver          = Oracle_ODBC_Driver_in_ora19c
DSN             = myDbCon.com
ServerName      = myDbCon.com

Obviously /var/opt/oracle/client2/lib/libsqora.so.19.1 exists and is executable or isql wouldn't work, correct?

I have verified all are 64 bit architecture so I "think" I just need to know where/how to set LD_LIBRARY_PATH so when called from php it knows where the driver is?

Upvotes: 0

Views: 238

Answers (1)

77Vetter
77Vetter

Reputation: 269

Found the problem, if we added LD_LIBRARY_PATH and ORACLE_HOME to /etc/sysconfig/httpd then it worked!!! Hope this helps someone else!

Upvotes: 1

Related Questions