PHP 中的 oci_connect 空白页
更新(2010年5月21日)成功!
因此,经过多次 $head->desk()'ing 后,我已经解决了它。
记住孩子们,要警惕您使用的即时客户端版本,这取决于虚拟化设置!
我一直在安装通用的 Instant Client(不知道我们的 ESX 服务器使用的是 AMD 处理器,而不是 Intel),并且在内部运行良好(CentOS 安装是 32 位的,因为我们的内部 ESXi 服务器不是 64 位的)。您瞧,即使您在 AMD64 虚拟化服务器上运行 32 位安装,您安装的即时客户端仍然很重要。
这是我想检查的最后一件事,但看起来,现在一切都运行良好。
我要感谢所有帮助我进行所有可能的测试来解决这个问题的人,但最终,我的错是没有意识到虚拟化的差异。
更新(2010 年 5 月 21 日) 当我在内部将其安装到新的虚拟机上时,我以为这个错误已经逃脱了我的注意,但现在我发现了一个缩小范围的链接。
当我发布此内容时,我正在尝试将其安装在我们的生产服务器上。经过一周毫无进展并需要重新开始开发后,我在内部服务器上安装了一个虚拟机,安装了全新的 Crap...CentOS,并全新安装了即时客户端和 oci8。
效果很好。
然而,我们只是将虚拟机的精确副本上传到我们的生产服务器,它就神奇地不再工作了。尝试重新安装一切,但无济于事。
因此,我唯一可以缩小范围的问题是防火墙问题(尽管我在尝试 127.0.0.1 时遇到了同样的问题)或可能是 ESX(我们的生产服务器)服务器问题,内部服务器正在运行 ESXi。
有什么想法吗?
更新 (3/8/2010) 我安装了 Xdebug 并让它跟踪我的代码。这是我得到的输出:
TRACE START [2010-03-08 17:53:05]
0.2090 327864 -> {main}() /data/aims3/http/octest.php:0
0.2091 327988 -> ini_set(string(14), string(1)) /data/aims3/http/octest.php:3
0.2093 327920 -> error_reporting(long) /data/aims3/http/octest.php:4
0.2094 328048 -> oci_connect(string(8), string(8), string(25)) /data/aims3/http/octest.php:6
跟踪在该点停止。
我已经在本地服务器上以相同的方式安装了所有内容,并且运行良好。如果说我完全不知所措,那就太轻描淡写了。
*注意:我运行了 make test,但每次测试都返回 FAIL。我从未在我的工作机器上运行过它来查看它是否报告相同的错误。知道为什么 make test 会报告 FAIL 但 make 不报告任何错误吗?
我已经安装了 Oracle Instantclient,没有报告任何错误以及 OCI8 PECL 软件包,但我却不知所措。每当我尝试使用 oci_connect 打开连接时,它都会停止我的整个 PHP 脚本。
示例:
<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
echo "before";
$conn = oci_connect("username", "password", "host");
echo "after";
?>
返回完整的空白页。该模块已加载(在 phpinfo 中可见)并且所有内容均已安装且没有错误。
我完全不知所措。
CentOS:5.4
Apache:2.2.3
PHP:5.3.1
InstantClient:11.2
oci8:1.4.1
有什么想法吗?
注释
Apache 错误日志未报告任何内容
尝试调试:
1:
<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
echo "before";
if(!function_exists('oci_connect')) die('Oracle Not Installed');
echo "after";
?>
返回:
beforeafter
2:
将主机更改为 //host
返回:
相同的错误
UPDATE (5/21/2010) SUCCESS!
So after MUCH $head->desk()'ing, I've solved it.
Remember kids, be wary of the instant client version you use, dependent on the virtualization settings!
I had been installing the generic Instant Client (not aware our ESX servers sit on AMD processors, not Intel) and that worked fine internally (the CentOS install was 32-bit since our internal ESXi servers aren't 64-bit). Well lo-and-behold, even if you have a 32-bit install running on a virtualized server which is sitting on an AMD64, it still matters what instant client you install.
It was the last thing I thought to check but as it appears, everything is running fine now.
I would like to thank everyone who helped me run through every possible test to figure this out but in the end, it was my fault for not realizing the differences in the virtualizations.
UPDATE (5/21/2010)
I thought this bug had escaped me when I installed it on a new VM internally but I have now found a narrowing link.
I was trying to install this on our production server when I posted this. After a week of no progress and in need to get back to development, I outfitted a VM on our internal server with a brand new install of Crap... CentOS, and fresh installs of instant client and oci8.
Worked perfectly.
However we just uploaded an exact copy of the VM to our production servers and it magically no longer works. Tried reinstalling everything, no avail.
So the only things I could narrow it down to is a firewall issue (although I get the same issue when trying 127.0.0.1) or possibly an ESX (our production servers) server issue, internal servers are running ESXi.
Any thoughts?
UPDATE (3/8/2010) I installed Xdebug and have it tracing my code. This is the output I am getting:
TRACE START [2010-03-08 17:53:05]
0.2090 327864 -> {main}() /data/aims3/http/octest.php:0
0.2091 327988 -> ini_set(string(14), string(1)) /data/aims3/http/octest.php:3
0.2093 327920 -> error_reporting(long) /data/aims3/http/octest.php:4
0.2094 328048 -> oci_connect(string(8), string(8), string(25)) /data/aims3/http/octest.php:6
The trace halts at that point.
I have installed everything the same way on a local server and it works fine. To say I am at a complete loss would be putting it lightly.
*NOTE: I ran make test and it returned FAIL on every test. I never ran this on my working machine to see if it reports the same errors. Any idea why make test would report FAIL but make doesn't report any error?
I've installed the Oracle Instantclient with no reported errors along with the OCI8 PECL package and at a loss. Whenever I try to open a connection with oci_connect, it halts my entire PHP script.
EXAMPLE:
<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
echo "before";
$conn = oci_connect("username", "password", "host");
echo "after";
?>
Returns a complete blank page. The module is loaded (seen in phpinfo) and everything installed with no errors.
I am at a complete loss.
CentOS: 5.4
Apache: 2.2.3
PHP: 5.3.1
InstantClient: 11.2
oci8: 1.4.1
Any thoughts?
NOTES
Apache Error Log reports nothing
Attempted Debugging:
1:
<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
echo "before";
if(!function_exists('oci_connect')) die('Oracle Not Installed');
echo "after";
?>
Returns:
beforeafter
2:
Changing host to //host
Returns:
Same error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Apache的error_log中有什么内容吗?这是mod_php还是FastCGI还是普通的CGI PHP?如果通过命令行运行脚本会发生什么?
您还可以尝试设置 PHP 的错误日志并往里面看。
EDIT1:尝试:
并发布结果...
EDIT2:我真的不确定。我最好的选择是来自 PHP 手册的信息:
还有人有什么想法可以帮助布莱恩吗?
Is there anything in Apache's error_log? Is this mod_php or FastCGI or normal CGI PHP? What happens if you run the script via the command line?
You could also try setting PHP's error log and looking in there.
EDIT1: Try:
And post the results...
EDIT2: I'm really not sure. My best bet is this info from the PHP manual:
Anyone else have any ideas to help out Bryan?
布莱恩,
说实话:我两年前尝试过,但惨败了。 :) 我无法通过自己编译来使 OCI 函数发挥作用。
但为了完成它,我寻找了替代解决方案,并在 Zend Core for Oracle 中找到了它。我所做的就是下载、运行安装程序,然后就完成了。它会为您安装 Apache/PHP、MySQL(可选)和 InstantClient。
现在作为 Zend Server,它基本上是相同的产品。我意识到这可能不是您希望的解决方案,但如果它有效...
Zend 服务器
Bryan,
I am going to be honest: I tried this two years ago and failed miserably. :) I could not get the OCI functions to work for anything by compiling myself.
But in the interest of getting it done I looked for an alternate solution and found it in Zend Core for Oracle. All I did was download, run the installer, and it was done. It installs Apache/PHP, MySQL (optional), and the InstantClient for you.
Now as Zend Server, it is basically the same product. I realize that this may not be the solution you hoped for, but if it works...
Zend Server
您连接到远程还是本地数据库?我认为,对于本地主机,您必须将“host”替换为“false”。我希望,这会对您有所帮助...
编辑:我认为,您缺少一个参数...我最后的建议是:1.您必须设置端口(默认1521)和/或2.您必须输入数据库名称和/或者您必须设置实例名称(ORACLE_SID 参数)
are you connecting to remote or to local db? i think, for localhost you must replace "host" with "false". I hope, this will help you...
edit: i think, you are missing a parameter...my last suggestions are: 1. you must set the port (default 1521) AND/OR 2. You must enter db name AND/OR you must set the instance name (the ORACLE_SID parameter)
您从不检查 oci_connect() 的返回值或调用 oci_error() 但它看起来与您的问题无关,因为您似乎遇到了 PHP 崩溃。 RHEL 有一个未解决的错误也可能会影响您:
http://pecl。 php.net/bugs/bug.php?id=16626
您自己构建了 oci8 软件包吗?您使用第三方二进制文件吗?
You never check the return value of oci_connect() or call oci_error() but it doesn't look relevant to your problem since you seem to be suffering from a PHP crash. There's an open bug for RHEL that may affect you too:
http://pecl.php.net/bugs/bug.php?id=16626
Did you build the oci8 package yourself? Are you using a third-party binary?
它已被修复。有关详细信息,请参阅顶部,但这里是悬崖注释:虚拟化环境很重要。
It has been fixed. See the top for details but here is the cliff notes: virtualiztion environments matter.