oracle 如何设置OCI从PHP连接到Oracle?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/238956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set up OCI to connect to Oracle from PHP?
提问by Sajee
On the latest Ubuntu, I have a functioning PHP 5.2.4 installation. I want to use a remote Oracle server from PHP using OCI.
在最新的 Ubuntu 上,我有一个正常运行的 PHP 5.2.4 安装。我想使用 OCI 从 PHP 使用远程 Oracle 服务器。
I've downloaded the "Instant Client Package - Basic Lite"(Link). I've unzipped the package containing the OCI libraries to a dir but I have no idea how to tell PHP that I want to use these libraries. Predictably, I get
我已经下载了“Instant Client Package - Basic Lite”(链接)。我已将包含 OCI 库的包解压缩到一个目录,但我不知道如何告诉 PHP 我想使用这些库。可以预见,我得到
Fatal error: Call to undefined function oci_connect() in...
致命错误:调用未定义的函数 oci_connect() in...
when running this code:
运行此代码时:
<?php
$conn = oci_connect('hr', 'hrpw', 'someremotehost');
?>
I don't want to recompile PHP with Oracle support. What's the fastest way to wire up PHP so that I can use Oracle? Do I need any other libaries, like the Oracle client if I want to connect to a remote Oracle instance?
我不想在 Oracle 支持下重新编译 PHP。连接 PHP 以便我可以使用 Oracle 的最快方法是什么?如果我想连接到远程 Oracle 实例,我是否需要任何其他库,例如 Oracle 客户端?
回答by Till
You need the PHP extension, try the following on your Ubuntu:
您需要 PHP 扩展,请在您的 Ubuntu 上尝试以下操作:
(sudo) pecl install oci8
Make sure your php.ini's (there should be one for your Apache and one for cli php) contain extension=oci8.so
afterwards. Finally, you have to restart Apache and can confirm via <?php phpinfo(); ?>
that the extension is loaded.
确保您的 php.ini(应该有一个用于您的 Apache,一个用于 cli php)包含extension=oci8.so
之后。最后,您必须重新启动 Apache 并可以通过<?php phpinfo(); ?>
加载扩展来确认。
UPDATE:
更新:
Enter something like this when it asks you for ORACLE_HOME:
当它要求您提供 ORACLE_HOME 时输入如下内容:
instantclient,/opt/oracle/instantclient
即时客户端,/opt/oracle/即时客户端
I think setting the environment variable would be another solution. /opt/oracle... is the path I put my instantclient in. I followed some tutorial a while ago, unfortunately I can't find it anmore.
我认为设置环境变量将是另一种解决方案。/opt/oracle... 是我放置 Instantclient 的路径。我不久前学习了一些教程,不幸的是我再也找不到了。
HTH
HTH
回答by m0j0
I think you'll need to make sure that the $ORACLE_HOME/lib32 is in your $LD_LIBRARY_PATH, or else add that directory to the /etc/ld.so.conf file.
我认为您需要确保 $ORACLE_HOME/lib32 在您的 $LD_LIBRARY_PATH 中,否则将该目录添加到 /etc/ld.so.conf 文件中。
回答by Sajee
In the end, I downloaded Zend Core for Oracle and that worked. http://www.zend.com/en/products/core/for-oracle
最后,我下载了用于 Oracle 的 Zend Core,并且奏效了。 http://www.zend.com/en/products/core/for-oracle