无法加载动态库 'C:xamppphpextphp_oci8.dll' - %1 不是有效的 Win32 应用程序

2022-01-14 00:00:00 xampp php oracle

我在启动 xampp 服务器时收到此错误.

I am getting this error when I start my xampp server.

C:xamppphpextphp_oci8.dll' - %1 不是有效的 Win32 应用程序.

C:xamppphpextphp_oci8.dll' - %1 is not a valid Win32 application.

我下载了 php_oci8-2.0.8-5.6-ts-vc11-x86 并将 php_oci8.dll 解压到 C:xamppphpext 目录.

I downloaded php_oci8-2.0.8-5.6-ts-vc11-x86 and extracted php_oci8.dll into C:xamppphpext directory.

另外,我下载了instantclient-basic-nt-12.1.0.2.0(32位版本),并将其添加到windows的PATH变量中.

Also, I downloaded instantclient-basic-nt-12.1.0.2.0 (32 bit version) and added the same to the PATH variable of windows.

C:OracleBasicClientinstantclient-basic-nt-12.1.0.2.0instantclient_12_1 添加到 PATH

不过,我收到了这个错误,不知道为什么会这样.

Still, I'm getting this error and not sure why it is coming.

我的窗口是 64 位的.

My windows is 64 bit.

PHP 信息 (xampp)

PHP info (xampp)

系统 Windows NT 6.1 (Windows 7 Professional) i586
编译器 MSVC11 (Visual C++ 2012)
架构 x86
线程安全启用

System Windows NT 6.1 (Windows 7 Professional) i586
Compiler MSVC11 (Visual C++ 2012)
Architecture x86
Thread Safety enabled

我可能做错了什么,我该如何解决?

What am I possibly doing wrong and how can I fix it?

推荐答案

您的错误显示内置类型不匹配.

Your error shows a built-type mismatch.

按照以下步骤解决:

确保您下载并安装 oracle instantclient:http://www.oracle.com/technetwork/topics/winsoft-085727.html,但请注意:

Make sure you download and install oracle instantclient at: http://www.oracle.com/technetwork/topics/winsoft-085727.html, but note:

  1. 记下您的 Oracle 数据库版本;对 Oracle 数据库 12c 使用 12.1.x 版,对于 11g 版本使用 11.1.x 版.
  2. 无论哪种情况,请确保您下载了 Oracle 即时客户端的 Basic Lite 版本.
  1. Take note of your Oracle database version; use Version 12.1.x for Oracle database 12c and Version 11.1.x for 11g releases.
  2. In either case, make sure you download the Basic Lite version of the Oracle instantclient.

之后,将 Oracle 即时客户端的位置添加到环境变量下的系统变量路径中.同样确保您的 xampp 及其 ext 的 PHP 都可用并在那里设置(如果没有,请添加它们).

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 xampp and its ext available and set there as well (if not, do add them).

然后,继续添加一个新的系统变量,其中 TNS_ADMIN 作为变量名,Oracle 即时客户端的位置 作为变量值.

Then, proceed to add a new System variable with TNS_ADMIN as variable name and the location to Oracle instantclient as variable value.

另外,使用与 值相同的Oracle Instantclient 位置定义您的用户变量PATH.

Also, define your User variables PATH with the same the location to Oracle instantclient as value.

在此阶段之后,重新启动计算机以完全传播新定义的环境变量.

After this stage, restart your computer for a full propagation of the newly defined environment variables.

打开后,您可以打开 Windows 命令提示符 并运行 where oci* 以确保您已明确定义了环境变量;响应应如下所示:

Once on, you may open your Windows Command Prompt and run where oci* to ensure that you had your environment variables well defined; the response should look like this:

C:Usersflex>where oci*

C:oraclexeapporacleproduct11.2.0serverinoci.dll
C:oraclexeapporacleproduct11.2.0serverinocijdbc11.dll
C:oraclexeapporacleproduct11.2.0serverinocijdbc11.sym
C:oraclexeapporacleproduct11.2.0serverinociw32.dll
C:instantclient_11_2oci.dll
C:instantclient_11_2oci.sym
C:instantclient_11_2ocijdbc11.dll
C:instantclient_11_2ocijdbc11.sym
C:instantclient_11_2ociw32.dll
C:instantclient_11_2ociw32.sym

如果没有,你一定错过了什么,需要重新审视这个过程,确保有效地完成它.

If not, your must have missed something and need to revisit the process, ensuring to completing it effectively.

您现在可以继续到您的 php.ini 文件(前提是环境变量定义良好)并通过取消注释来启用您的 oci 扩展(php_oci8.dll 和 php_oci8_11g.dll);您可以通过简单地删除上述扩展之前的半列 (;) 来实现.

You may now proceed to your php.ini file (provided environment variables are well defined) and enable your oci extensions (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 文件,然后,如果 apache 尚未运行,请重新启动或启动它.

Do remember to save your php.ini file, then, restart or start your apache if it isn't already running.

要检查您的 PHP oci8 配置是否启用,您可以返回 Windows 命令提示符并运行:php --ri oci8;响应应类似于以下响应:

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:

C:Usersflex>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

或者,您可以使用 <?php phpinfo(); 创建一个 PHP 文件.?> 作为内容,然后在浏览器中打开并搜索 oci8 出现;它也应该在那里显示启用.

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.

相关文章