php 无法加载 oci8 -> 致命错误:调用未定义的函数 oci_connect()

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

can not load oci8 -> Fatal error: Call to undefined function oci_connect()

phporacleocioci8

提问by allrise

I want to connect to my oracle database, but i have a problem with function oci_connect. i have tried to uncomment this:

我想连接到我的 oracle 数据库,但函数 oci_connect 有问题。我试图取消注释:

extension=php_oci8.dll 

but, still have an error :

但是,仍然有一个错误:

Fatal error: Call to undefined function oci_connect() in C:\xampp\htdocs\testing\db.php on line 71

致命错误:在第 71 行调用 C:\xampp\htdocs\testing\db.php 中未定义的函数 oci_connect()

But, when i check in phpinfo(), oci8 still not loaded and i can not connect to my oracle database. i already restart my apache. How i fix this problem ? Canyou help me?

但是,当我检查 phpinfo() 时,oci8 仍然没有加载,我无法连接到我的 oracle 数据库。我已经重新启动了我的 apache。我如何解决这个问题?你能帮助我吗?

Thank you..

谢谢..

回答by R?mulo Z. C. Cunha

In Ubuntu 16.04, using PHP 5.6, with 64bit os, try this:

在 Ubuntu 16.04 中,使用 PHP 5.6,使用 64 位操作系统,试试这个:

Install the packages:

安装软件包:

sudo apt-get install php5.6-dev build-essential php-pear libaio1

Download the latest version of the packages from:

从以下位置下载最新版本的软件包:

http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Search for these packages, according with the latest version:

根据最新版本搜索这些包:

oracle-instantclientXX.X-basic-XX.X.X.X.X-X.x86_64.rpm
oracle-instantclientXX.X-devel-XX.X.X.X.X-X.x86_64.rpm

Converting packages:

转换包:

sudo apt-get install alien
sudo alien oracle-instantclientXX.X-basic-XX.X.X.X.X-X.x86_64.rpm
sudo alien oracle-instantclientXX.X-devel-XX.X.X.X.X-X.x86_64.rpm

Installing:

安装:

sudo dpkg -i oracle-instantclientXX.X-basic_XX.X.X.X.X-X_amd64.deb
sudo dpkg -i oracle-instantclientXX.X-devel_XX.X.X.X.X-X_amd64.deb

Installing oci8:

安装oci8:

sudo pecl install oci8-2.0.12

*Build process completed successfully
Installing '/usr/lib/php/20131226/oci8.so'
install ok: channel://pecl.php.net/oci8-2.0.12
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini*

Add the extension to php:

将扩展添加到 php:

sudo gedit /etc/php/5.6/apache2/php.ini

add the extension:

添加扩展名:

extension=oci8.so

Restart apache:

重启阿帕奇:

sudo service apache2 restart

That's it.

就是这样。

回答by timclutton

In php.iniensure that you enable the correct OCI extension (11g), like this:

php.ini确保启用了正确的OCI扩展(11克),就像这样:

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

As long as you've got Oracle 11gR2 or greater client librariescorrectly installed you should now be able to run:

只要您正确安装了Oracle 11gR2 或更高版本的客户端库,您现在应该能够运行:

C:\>php --ri oci8

And get the result:

并得到结果:

oci8

OCI8 Support => enabled
Version => 1.4.10
Revision => $Id: b0984d94e17f7c099470cd0a9404259f2a59da04 $
Active Persistent Connections => 0
Active Connections => 0
Oracle Run-time Client Library Version => 11.2.0.3.0
Oracle Instant Client Version => 11.2
Temporary Lob support => enabled
Collections support => enabled

Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off

To check your Oracle client is installed correctly (i.e., in your environment PATHvariable) you can run:

要检查您的 Oracle 客户端是否正确安装(即在您的环境PATH变量中),您可以运行:

C:\>where oci*

You should get a result like this:

你应该得到这样的结果:

C:\instantclient_11_2\oci.dll
C:\instantclient_11_2\oci.sym
C:\instantclient_11_2\ocijdbc11.dll
C:\instantclient_11_2\ocijdbc11.sym
C:\instantclient_11_2\ociw32.dll
C:\instantclient_11_2\ociw32.sym

回答by njoshsn

Follow the offcial link for me Oracle

按照我的官方链接 Oracle

http://www.oracle.com/technetwork/articles/dsl/technote-php-instant-084410.html

http://www.oracle.com/technetwork/articles/dsl/technote-php-instant-084410.html

Here is what worked with Xammp

这是与 Xammp 一起使用的内容

1.uncomment extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client if you are using 11g (in php.ini)

1.取消注释扩展名=php_oci8_11g.dll;如果您使用的是 11g(在 php.ini 中),请与 Oracle 11gR2 Instant Client 一起使用

2.add AddHandler fcgid-script .php to httpd.conf

2.添加AddHandler fcgid-script .php到httpd.conf

3.Download the FastCGI component mod_fcgid-2.3.6-win32-x86.zip from httpd.apache.org/download.cgi#mod_fcgid

3.Download从FastCGI的部件mod_fcgid-2.3.6-win32-x86.zip httpd.apache.org/download.cgi#mod_fcgid

4.Unzip it to the installed Apache 2.2 directory. The C:\xamp\apache\modules directory should now have mod_fcgid.so and mod_fcgid.pdb files.

4.解压到安装的Apache 2.2目录。C:\xamp\apache\modules 目录现在应该有 mod_fcgid.so 和 mod_fcgid.pdb 文件。

5.Download the "Instant Client Package - Basic" for Windows from the OTN Instant Client page. Because PHP is 32 bit, use the 32 bit version of Instant Client.

5.从OTN Instant Client 页面下载适用于Windows 的“Instant Client Package - Basic”。因为 PHP 是 32 位的,所以使用 32 位版本的 Instant Client。

Unzip the Instant Client files to C:\instantclient_11_2

将 Instant Client 文件解压到 C:\instantclient_11_2

Edit the Windows PATH environment setting and add C:\instantclient_11_2. For example, on Windows XP, follow Start -> Control Panel -> System -> Advanced -> Environment Variables and edit PATH in the System variables list.

编辑 Windows PATH 环境设置并添加 C:\instantclient_11_2。例如,在 Windows XP 上,按照开始 -> 控制面板 -> 系统 -> 高级 -> 环境变量并在系统变量列表中编辑 PATH。

Commonly you need to reboot Windows so the new environment is correctly set.

通常您需要重新启动 Windows 才能正确设置新环境。

that worked for me all the best

这对我很有效

回答by Rashy

Have a look at RO_engineer's answer of installing x86 files of Oracle insta client rather than x64 version. It resolved my issue, may be that can help you too.

看看RO_engineer安装 Oracle insta 客户端的 x86 文件而不是 x64 版本的答案。它解决了我的问题,也许对你也有帮助。

https://stackoverflow.com/a/27177616/289587

https://stackoverflow.com/a/27177616/289587

Download Instant Client for Microsoft Windows (32-bit)

下载适用于 Microsoft Windows 的 Instant Client(32 位)