oracle 无法加载动态库 'C:\xampp\php\ext\php_oci8.dll' - %1 不是有效的 Win32 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33220825/
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
Unable to load dynamic library 'C:\xampp\php\ext\php_oci8.dll' - %1 is not a valid Win32 application
提问by Ramanuj Srivastava
I am getting this error when I start my xampp server.
启动 xampp 服务器时出现此错误。
C:\xampp\php\ext\php_oci8.dll' - %1 is not a valid Win32 application.
C:\xampp\php\ext\php_oci8.dll' - %1 不是有效的 Win32 应用程序。
I downloaded php_oci8-2.0.8-5.6-ts-vc11-x86
and extracted php_oci8.dll
into C:\xampp\php\ext
directory.
我下载php_oci8-2.0.8-5.6-ts-vc11-x86
并解压php_oci8.dll
到C:\xampp\php\ext
目录中。
Also, I downloaded instantclient-basic-nt-12.1.0.2.0
(32 bit version) and added the same to the PATH variable of windows.
另外,我下载了instantclient-basic-nt-12.1.0.2.0
(32 位版本)并将其添加到 windows 的 PATH 变量中。
C:\OracleBasicClient\instantclient-basic-nt-12.1.0.2.0\instantclient_12_1
added to PATH
C:\OracleBasicClient\instantclient-basic-nt-12.1.0.2.0\instantclient_12_1
添加到路径
Still, I'm getting this error and not sure why it is coming.
尽管如此,我还是收到了这个错误,并且不确定它为什么会出现。
My windows is 64 bit.
我的 Windows 是 64 位的。
PHP info (xampp)
PHP 信息 (xampp)
SystemWindows NT 6.1 (Windows 7 Professional) i586
CompilerMSVC11 (Visual C++ 2012)
Architecturex86
Thread Safetyenabled
系统Windows NT 6.1 (Windows 7 Professional) i586
CompilerMSVC11 (Visual C++ 2012)
Architecturex86
Thread Safetyenabled
What am I possibly doing wrong and how can I fix it?
我可能做错了什么,我该如何解决?
回答by nyedidikeke
Your error shows a built-type mismatch.
您的错误显示内置类型不匹配。
Resolve it by following these steps:
按照以下步骤解决:
Make sure you download and install oracle instantclientat: http://www.oracle.com/technetwork/topics/winsoft-085727.html, but note:
确保在以下位置下载并安装 oracle Instantclient:http: //www.oracle.com/technetwork/topics/winsoft-085727.html,但请注意:
- Take note of your Oracledatabase version; use Version 12.1.xfor Oracle database 12cand Version 11.1.xfor 11greleases.
- In either case, make sure you download the Basic Liteversion of the Oracle instantclient.
- 记下您的Oracle数据库版本;使用版本12.1.x对于Oracle数据库12C和版本11.1.x为11克版本。
- 无论哪种情况,请确保下载Oracle 即时客户端的Basic Lite版本。
After that, do add location of your Oracle instantclient to your System variable Path under your Environment Variables. Do equally ensure that you have both the PHP of your xamppand its extavailable and set there as well (if not, do add them).
之后,将 Oracle 即时客户端的位置添加到环境变量下的系统变量路径中。同样确保您拥有xampp的 PHP和它的ext可用,并在那里设置(如果没有,请添加它们)。
Then, proceed to add a new System variable with TNS_ADMINas variable nameand the location to Oracle instantclientas variable value.
然后,继续添加一个新的系统变量,其中TNS_ADMIN作为变量名,并将 Oracle 即时客户端的位置作为变量值。
Also, define your User variables PATHwith the same the location to Oracle instantclientas value.
此外,定义用户变量PATH具有相同的位置,甲骨文instantclient的价值。
After this stage, restart your computer for a full propagation of the newly defined environment variables.
在此阶段之后,重新启动计算机以完全传播新定义的环境变量。
Once on, you may open your Windows Command Promptand run where oci*to ensure that you had your environment variables well defined; the response should look like this:
打开后,您可以打开Windows 命令提示符并运行where oci*以确保您已定义好环境变量;响应应如下所示:
C:\Users\flex>where oci*
C:\oraclexe\app\oracle\product.2.0\server\bin\oci.dll
C:\oraclexe\app\oracle\product.2.0\server\bin\ocijdbc11.dll
C:\oraclexe\app\oracle\product.2.0\server\bin\ocijdbc11.sym
C:\oraclexe\app\oracle\product.2.0\server\bin\ociw32.dll
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
If not, your must have missed something and need to revisit the process, ensuring to completing it effectively.
如果没有,您一定错过了一些东西,需要重新审视这个过程,确保有效地完成它。
You may now proceed to your php.ini file (provided environment variables are well defined) and enable your ociextensions (php_oci8.dll and php_oci8_11g.dll) by uncommenting them; you can achieve that by simply removing the semi column (;) before the said extensions.
您现在可以继续处理您的 php.ini 文件(提供的环境变量定义良好)并通过取消注释来启用您的oci扩展(php_oci8.dll 和 php_oci8_11g.dll);您可以通过简单地删除上述扩展名之前的半列 ( ;)来实现这一点。
Do remember to save your php.ini file, then, restart or start your apache if it isn't already running.
请记住保存您的 php.ini 文件,然后重新启动或启动您的 apache(如果它尚未运行)。
To check your PHP oci8 configurations are enabled, you may go back to your Windows Command Prompt and run: php --ri oci8; the response should be similar to the one below:
要检查您的 PHP oci8 配置是否已启用,您可以返回 Windows 命令提示符并运行:php --ri oci8; 响应应与以下类似:
C:\Users\flex>php --ri oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.1
Revision => $Id: 86f22a208f89dcd5b305e82929a7429683968b11 $
Oracle Run-time Client Library Version => 11.2.0.4.0
Oracle Compile-time Instant Client Version => 10.2
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.events => Off => Off
Statistics =>
Active Persistent Connections => 0
Active Connections => 0
Alternatively, you can create a PHP file with <?php phpinfo(); ?>
as content, then open it in your browser and search for oci8 occurrences; it should show enabled there as well.
或者,您可以创建一个包含<?php phpinfo(); ?>
as 内容的 PHP 文件,然后在浏览器中打开它并搜索 oci8 事件;它也应该在那里显示启用。
回答by Ben Johnson
It seems that you downloaded the DLL for a different architecture and pointed to it in your php.ini
, instead of using the bundled DLL and simply un-commenting the default entry in php.ini
.
看来你下载的DLL为不同的体系结构,并在您指出了它php.ini
,而不是使用捆绑的DLL和简单地取消注释中的默认项php.ini
。
I just downloaded the same version, XAMPP 3.2.2 x86, with PHP 7.1, and it shipswith the DLL file that you need, which is installed to C:\xampp\php\ext\php_oci8_12c.dll
.
我刚刚用 PHP 7.1 下载了相同的版本 XAMPP 3.2.2 x86,它附带了您需要的 DLL 文件,该文件安装到C:\xampp\php\ext\php_oci8_12c.dll
.
You appear to have done everything else correctly.
你似乎已经正确地完成了其他所有事情。
To fix the issue, ensure that the effective php.ini
(by default, C:\xampp\php\php.ini
) references onlythe default file (remove the erroneous entry you added for php_oci8.dll
), like so:
要解决此问题,请确保有效php.ini
(默认情况下,C:\xampp\php\php.ini
)仅引用默认文件(删除您添加的错误条目php_oci8.dll
),如下所示:
extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
Restart Apache and the problem should be resolved.
重启Apache,问题应该解决了。