来自 PHP 连接的 Linux Oracle unix_odbc 不起作用
我使用 oracle 客户端 19 (tnsnames.ora) 在 RHEL 上运行 php v5 我有 odbcinst.ini 和 odbc.ini 设置,并且正在通过命令提示符工作:
isql -v myOdbc username pw
我必须指定 LD_LIBRARY_PATH 才能使其正常工作。但是现在,当我在 php 中运行测试页面并尝试 odbc_connect 命令时,它给出以下错误:“无法打开 lib '/var/opt/oracle/client2/lib/libsqora.so.19.1'” -这是 LD_LIBRARY_PATH 中的值
所以看来 LD_LIBRARY_PATH 没有为 Apache 或 PHP 设置正确?如果我
php --info
这样做,则会返回: _SERVER["LD_LIBRARY_PATH"] => /var/opt/oracle/client2/lib 所以 PHP“似乎”知道 LD_LIBRARY_PATH 但不知何故 Apache 或其他东西不知道?
这是 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
这是 odbc.ini
[myOdbc]
Description = wilson
Driver = Oracle_ODBC_Driver_in_ora19c
DSN = myDbCon.com
ServerName = myDbCon.com
显然 /var/opt/oracle/client2/lib/libsqora.so.19.1 存在并且可执行,否则 isql 将无法工作,对吗?
我已经验证了所有都是 64 位架构,所以我“认为”我只需要知道在哪里/如何设置 LD_LIBRARY_PATH,这样当从 php 调用时它知道驱动程序在哪里?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发现问题了,如果我们将 LD_LIBRARY_PATH 和 ORACLE_HOME 添加到 /etc/sysconfig/httpd 就可以了!希望这对其他人有帮助!
Found the problem, if we added LD_LIBRARY_PATH and ORACLE_HOME to /etc/sysconfig/httpd then it worked!!! Hope this helps someone else!