安装并配置 OCI8 以将 oracle 连接到 php
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25519686/
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
install and configure OCI8 to connect oracle to php
提问by user3891365
I installed oracle 11g and I did create some tables and manipulate it using sql developer, and I am looking for a way to connect oracle with php on hosting site.
我安装了 oracle 11g,我确实创建了一些表并使用 sql developer 操作它,我正在寻找一种方法来将 oracle 与托管站点上的 php 连接起来。
I tried but I get error after using this code:
我试过了,但在使用此代码后出现错误:
$Conexion_ID =oci_connect($OracleUser, $OraclePassw, $OracleIP);
this is the error:
这是错误:
Call to undefined function oci_connect()
I've known that I should install and configure OCI8, so I downloaded this file:
我知道我应该安装和配置 OCI8,所以我下载了这个文件:
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
but I don't know in which folder should I them to make the connection work well.
但我不知道应该在哪个文件夹中才能使连接正常工作。
回答by Jigar
Download the PHP Extension from here(Confirm the PHP Version and download for the same, the thread safe[TS] version): http://pecl.php.net/package/oci8/2.0.8/windows
从这里下载 PHP 扩展(确认 PHP 版本并下载相同的线程安全 [TS] 版本):http: //pecl.php.net/package/oci8/2.0.8/windows
You should be able to find three .dll's
您应该能够找到三个 .dll
php_oci8.dll, php_oci8_11g.dll and php_oci8_12c.dll
php_oci8.dll、php_oci8_11g.dll 和 php_oci8_12c.dll
Place all dll's in extension directory, in WAMP it is generally wamp\bin\php\php5.*.*\ext
将所有dll放在扩展目录中,在WAMP中一般是 wamp\bin\php\php5.*.*\ext
open the php configuration from the System try of wamp server and add the line:
从 wamp 服务器的 System try 打开 php 配置并添加以下行:
; Enable only which is required
;extension=php_oci8.dll
extension=php_oci8_11g.dll
;extension=php_oci8_12c.dll
Restart the Apache server.
重新启动 Apache 服务器。
EDIT: Sorry I thought the other dll's are the libraries, but instead they are for different oracle versions. In your case enable 11g. Answer updated.
编辑:抱歉,我认为其他 dll 是库,但它们用于不同的 oracle 版本。在你的情况下启用 11g。答案已更新。
Update 2016-11-07: just wanted to say that latest package can be found here https://pecl.php.net/package/oci8. When I wrote this answer 2.0.8 was latest i guess.
2016 年 11 月 7 日更新:只是想说最新的包可以在这里找到https://pecl.php.net/package/oci8。当我写这个答案时,我猜 2.0.8 是最新的。
回答by Ram Sharma
if you are using wamp server on windows than you have to use the php_oci8.dll
not the oci8.so
. You need to download php_oci8.dll
and copy it to ext
directory under the PHP. If you don't have this extension in your PHP than install it and go to php.ini
and add extension=php_oci8.dll
.
如果您在 Windows 上使用 wamp 服务器,则必须使用php_oci8.dll
not the oci8.so
. 您需要下载php_oci8.dll
并复制到ext
PHP 下的目录中。如果您的 PHP 中没有此扩展程序,请安装它并转到php.ini
并添加extension=php_oci8.dll
.
Please make sure that wamp server have two php.ini files you have to change it on both the places. once everything is done than check with php info that oci 8 installed or not.
请确保 wamp 服务器有两个 php.ini 文件,您必须在两个地方更改它。一切都完成后,请检查是否已安装 oci 8 的 php 信息。