Oracle 11g PHP oci_connect失败OCIEnvNlsCreate() [英] Oracle 11g PHP oci_connect fails OCIEnvNlsCreate()

查看:711
本文介绍了Oracle 11g PHP oci_connect失败OCIEnvNlsCreate()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:Linux CentOS/Oracle 11g/InstantClient/PHP 5.3.3

Problem: Linux CentOS/Oracle 11g/InstantClient/PHP 5.3.3

错误:oci_connect():OCIEnvNlsCreate()失败.您的系统有问题-请检查ORACLE_HOME和LD_LIBRARY_PATH是否已设置并指向正确的目录

Error: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and LD_LIBRARY_PATH are set and point to the right directories

phpinfo()相关章节:

phpinfo() relevant sections:

如您所见,环境变量已正确设置,我可以使用getenv()在页面上回显它们.我还检查了读取权限,并且可以从网页中读取这些目录中的所有文件.客户端库文件已完全安装(我已安装并重新安装了两次).这些库可读且可加载.

As you see, the environment variables are correctly set, and I can echo them on the page with with getenv(). I also checked the read permissions and I can read all the files in these directories from the webpage. The client library files are there (I installed and reinstalled twice) full install. The libraries are readable and loadable.

ldd没有显示任何错误.

ldd did not show any errors.

这是来自php文件的呼叫:

Here is the call from php file:

$test = getenv('LD_LIBRARY_PATH')."  ".getenv('ORACLE_HOME');
$this->dbconn = oci_connect("myuser","mypassword", "localhost/orcl") or die("<b>Connection Failed: $test </b>").oci_error();

我尝试了从谷歌搜索中找到的所有技巧,但没有任何效果.
感谢您的帮助.

I tried all the tricks I found from googling, nothing worked.
Any help is appreciated.

推荐答案

OCIEnvNlsCreate()失败了吗?欢迎来到地狱...

Got OCIEnvNlsCreate() failed? Welcome to hell...

我知道线程很旧,但是问题仍然存在.通常,此问题的答案将重定向到第三方站点,通常是404s.

I know that the thread is old, but the problem is still present. And usually the answers to this problem redirect to third party sites, usually 404s .

让我们从问题开始.该错误本身是非常普通的.其文档总结为"lib crash ... dunno why".有各种各样的解决方案,包括但不限于配置,重新安装和祈祷在此处插入随机的神的名字".

Let's start with the problem. The error itself is pretty generic. Its documentation sums up to "lib crashed...dunno why". There is a wide range of solutions including, but not limited to configuring, reinstalling and praying to "insert random god name here".

以下是最常见的解决方案的简短列表:

Here is a short list of the most common solutions:

1.将变量放入您的.php文件中.

    putenv("LD_LIBRARY_PATH=$newld");

where $newld is the link to your library.

2.从您的php文件中删除变量LD_LIBRARY_PATH (如果存在)(是的,它在1中显示的方式),并将其放入您的apache2.conf或httpd.conf或/etc/environment或您分发的任何文件中/version具有用于环境变量.可以在此处或互联网上的任何地方找到简单指南.为什么?

2. Remove the variable LD_LIBRARY_PATH, if exists(yeah, the way it was shown in 1.), from your php file and place it into your apache2.conf or httpd.conf or /etc/environment or whatever file your distribution/version has for the environment variables. A simple guide can be found here or everywhere on the internet. Why?

请勿在PHP脚本中使用putenv()设置Oracle环境变量 因为Oracle库可能会在您加载之前初始化并初始化 脚本运行.然后,使用putenv()设置的变量可能会导致冲突, 崩溃或不可预测的行为.某些功能可能有效,但其他功能 可能会给出细微的错误.变量应在 Web服务器已启动.

Do not set Oracle environment variables using putenv() in a PHP script because Oracle libraries may be loaded and initialized before your script runs. Variables set with putenv() may then cause conflicts, crashes, or unpredictable behavior. Some functions may work but others might give subtle errors. The variables should be set up before the web server is started.

如安装文档中所述.然后也重新启动apache.它基于发行版/版本,但是最有可能的命令是service httpd restart.

as stated in the installation docs. Also restart apache afterwards. It's distribution/version based, but most probably the command is service httpd restart.

  1. 重新安装oci8 .尽可能多的次数.不要强迫它.强迫只会使情况变得更糟.另外,尝试对其进行编译(也可以使用./configure -'all the fancy commands you'll need to use'然后使用make install下载该软件包).

  1. Reinstall oci8. As many times as it take. Don't force it. Forcing only makes it worse. Also, try to compile it (aka download the package use ./configure -'all the fancy commands you'll need to use' and then make install).

确保您使用了正确的LD_LIBRARY_PATH .有趣的话,对不对?您可能没有注意到oracle在 N个不同位置中创建了文件夹client/lib/,该文件夹包含或多或少的相同文件,它们之间的唯一区别是,除了这些文件夹之一将导致上述错误.健全性检查?

Make sure u got the right LD_LIBRARY_PATH. Funny thing to say, right? You probably didn't notice that oracle created the folder client/lib/ in N different locations which contains more or less the same files, and the only difference, between them, is that choosing all but one of those folders will result in the mentioned error. Sanity check?

重新安装php/apache .您可能有一些过时的安装导致了问题.因此,使用apt-get purge php*yum remove php*或其他与您的发行版相同的技巧将是一个不错的开始.

Reinstall php/apache. It's probable that you had some old installation that is causing issues. So use apt-get purge php* or yum remove php* or whatever does the same trick for your distribution, will be a good start.

编辑 PHP升级后,再次出现此问题,这是另一种解决方法.

EDIT After PHP upgrade the problem reoccurred, this time with a different solution.

  1. 编辑SYSCONFIG 编辑文件/etc/sysconfig/httpd.在末尾添加这两行:

  1. EDIT SYSCONFIG Edit the file /etc/sysconfig/httpd. Add those 2 lines at the end:

导出LD_LIBRARY_PATH =/path/to.lib 导出ORACLE_HOME =/path/to/home

export LD_LIBRARY_PATH=/path/to.lib export ORACLE_HOME=/path/to/home

放弃并阅读手册,可以找到如果这些都不起作用,请随时浏览悲伤之墙,寻求解决方案...

If none of those things help, feel free to browse the wall of sorrow, for a solution...

这篇关于Oracle 11g PHP oci_connect失败OCIEnvNlsCreate()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆