如何在 win7 x64 上使用带有 php (xampp) 的 oracle 客户端 11.2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27774337/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:30:57  来源:igfitidea点击:

How to use oracle client 11.2 with php (xampp) on win7 x64

phporacleapacheoracle11goracleclient

提问by bish

I just installed an acutal XAMPP on my win7 (x64) PC to write some PHP scripts to connect to an oracle DB. I also have a normal oracle 11.2.0 client installed (PATH and ORACLE_HOME are set correctly). The client is used for all my other work without any problems.

我刚刚在我的 win7 (x64) PC 上安装了一个真实的 XAMPP 来编写一些 PHP 脚本来连接到一个 oracle DB。我还安装了一个普通的 oracle 11.2.0 客户端(PATH 和 ORACLE_HOME 设置正确)。客户端用于我的所有其他工作,没有任何问题。

When I try to connect to an oracle DB PHP fails with Fatal error: Call to undefined function oci_connect() in. I remember I had to enable the "oci8-extensions" in my php.ini when I did the same thing some years ago on a x32 winXP PC. But my current xampp does not have these dll in the php/extfolder (only a php_oci8_12c.dllwhich throws several errors of unknown functions on apache start and which is for oracle 12 and not 11) and the php.ini also says they are only needed for the instant client.

当我尝试连接到 Oracle DB 时,PHP 失败并显示Fatal error: Call to undefined function oci_connect() in. 我记得几年前我在 x32 winXP PC 上做同样的事情时,我不得不在我的 php.ini 中启用“oci8-extensions”。但是我当前的 xampp 在php/ext文件夹中没有这些 dll (只有一个php_oci8_12c.dll会在 apache 启动时抛出几个未知函数的错误,并且它是针对 oracle 12 而不是 11),并且 php.ini 也说它们只需要即时客户端.

;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client

Also this SO-questionsshows that using the comment extension with a normal client will not work (which I also tried).

此外,这个SO-questions表明在普通客户端上使用评论扩展是行不通的(我也试过)。

I tried to google for a solution but all "solutions" are "install win32 instant client and enable extension". But I can`t do this as most of my QA-work requires the installed and configured 11.2.0-client and I don't have the .dll in my php/ext-folder anyway

我试图用谷歌搜索解决方案,但所有“解决方案”都是“安装 win32 即时客户端并启用扩展”。但是我不能这样做,因为我的大部分 QA 工作都需要安装和配置的 11.2.0 客户端,而且我的 php/ext 文件夹中没有 .dll

I also tried to copy the ociw32.dll from the client/bin folder to the php/ext-folder but then apache says it's not an PHP-library.

我还尝试将 ociw32.dll 从 client/bin 文件夹复制到 php/ext 文件夹,但 apache 说它不是 PHP 库。

So how can I enable PHP oracle libraries to use oci8 for XAMPP on x64 win7 WITHOUTinstalling win32 Oracle Instant Client and destroying my current setting?

那么如何在安装 win32 Oracle Instant Client 并破坏我当前设置的情况下,让 PHP oracle 库在 x64 win7 上使用 oci8 进行 XAMPP呢?

edit: I also tried the steps described in the PHP: Installation Manual (Post of: samantha dot vincent at gmail dot com)including changing my apache-http.conf which also didn't help.

编辑:我还尝试了PHP:安装手册(发布:samantha dot vincent at gmail dot com)中描述的步骤包括更改我的 apache-http.conf 也没有帮助。

I'm also confused of my phpinfo()-Output as it says

我也很困惑我的phpinfo()-Output 正如它所说的

Configure Command   "--with-pdo-oci=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared"

回答by bish

I finally found a solution:

我终于找到了解决办法:

I downloaded the actual OCI-DLLs from "PECL :: PAckage :: oci8 :: 2.0.8"(in my case the 32bit, threadsafe DLL) and then removed the ;from this line

我从“PECL :: PAckage :: oci8 :: 2.0.8”(在我的例子中是 32 位线程安全 DLL)下载了实际的 OCI-DLL ,然后;从这一行中删除了

;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client

I also added the following lines to my http.conf of apache

我还在我的 apache 的 http.conf 中添加了以下几行

SetEnv ORACLE_BASE "C:/oracle/"
SetEnv ORACLE_HOME "C:/oracle/product/11.2.0/client_1"  

After that I restarted apache, made sure that my connection-alias is probably placed in my tsnames.oraand then I could use the oci8-functions witout any problems.

在那之后,我重新启动了 apache,确保我的连接别名可能放在我的中tsnames.ora,然后我可以使用 oci8 函数而不会出现任何问题。

回答by Yvan Serrata

  1. https://pecl.php.net/package/oci8/2.2.0/windowsSELECT -> 7.3 Thread Safe (TS) x86 for 32bits or 7.3 Thread Safe (TS) x64 for 64 bits
  2. Extract all files and copy into de C:\xampp\php\ext
  3. Open php.ini file and write this: extension=php_oci8.dll
  4. Restart xampp. check your browser http://localhost/dashboard/phpinfo.phpif the oci8 is enabled if not appear. download from internet and copy the oci8.dll into the c:\windows\system32 folder.
  5. Restart xampp
  6. Check your browser http://localhost/dashboard/phpinfo.phpif the oci8 is enabled. Done!!
  1. https://pecl.php.net/package/oci8/2.2.0/windowsSELECT -> 32 位为 7.3 线程安全 (TS) x86 或 64 位为 7.3 线程安全 (TS) x64
  2. 提取所有文件并复制到 de C:\xampp\php\ext
  3. 打开 php.ini 文件并写入:extension=php_oci8.dll
  4. 重新启动 xampp。检查您的浏览器http://localhost/dashboard/phpinfo.php是否启用了 oci8 如果没有出现。从 Internet 下载并将 oci8.dll 复制到 c:\windows\system32 文件夹中。
  5. 重启xampp
  6. 如果 oci8 已启用,请检查您的浏览器http://localhost/dashboard/phpinfo.php。完毕!!