php_oci8_11g.dll不是有效的Win32应用程序
This topic has been asked several times, but every solution is not working in my machine.
I am trying to connect windows 7 with a 10G oracle dabatase, but the oci extension is not loaded. Here some facts:
C:\php>php -m
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_oci8_11g.dll' - %1 is not a valid Win32 application.
C:\php>php -v
PHP 5.6.19 (cli) (built: Mar 2 2016 20:09:42)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
- 64x architecture
- TS VC11
C:\>tnsping localdb
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 02-AUG-2
016 22:37:50
Troubleshooting
- I am using oci8 2.0.11. Dropped them in
ext/
folded. The rest of extesions are loaded pretty good. - PATH variable contains the ORACLE_HOME and php path
-
Just looked up for required oracle dll files and they are there:
C:\>where oci*
C:\oracle\product\10.2.0\db_2\BIN\oci.dll C:\oracle\product\10.2.0\db_2\BIN\ocijdbc10.dll C:\oracle\product\10.2.0\db_2\BIN\ociw32.dll
- Oracle Client is not required in my side because the database is installed in the same machine, and it install all the required libraries
What other thing am I missing? Thank you in advance
本主题已被多次询问,但每个解决方案都无法在我的机器中运行。 p>
我正在尝试将Windows 7与10G oracle dabatase连接,但未加载oci扩展名。 这里有一些事实: p>
PHP警告:PHP 启动:无法加载动态库'C:\ php \ ext \ php_oci8_11g.dll' - %1不是有效的Win32应用程序。 p>
blockquote>
故障排除
只需查找所需的oracle dll文件,它们就在那里 : p>
我还缺少什么? 提前谢谢 p>
div> C:\ php> php -m code> p>
C :\ php> php -v code> p>
PHP 5.6.19(cli)(建于2016年3月2日20:09:42)
版权所有(c)1997 -2016 PHP Group
Zend Engine v2.6.0,版权所有(c)1998-2016 Zend Technologies
code> pre>
C:\> tnsping localdb code> p>
适用于32位Windows的TNS Ping实用程序:版本10.2.0.1.0 - 生产于02-AUG-2
016 22:37:50
code> pre>
ext / code>折叠中。 其余的extesions加载得非常好。 li>
C:\>其中oci * code> p>
C:\ oracle \ product \ 10.2。 0 \ db_2 \ BIN \ OCI.DLL \ NC:\ ORACLE \产品\ 10.2.0 \ db_2 \ BIN \ ocijdbc10.dll \ NC:\ ORACLE \产品\ 10.2.0 \ db_2 \ BIN \ OCIW32.DLL
pre> li>
After months I found the solution. Consider the following infrastructure:
- Windows Server 2012 R2 Standard Edition x64
- Apache/2.4.18 (Win64) VC11
- PHP 5.6.19 x86 VC11 TS
Take close attention when downloading Oracle Instant Client:
- No matter if your server is x64 or x86 arquitecture, you must download it for 32-bits
- As you note, PHP is compiled in VC11, so you must download OIC with VC11 sources, this can be confirmed unzipping the downloaded file and check if a folder vc11 is there.
Both details are very important. Once I meet both requirements the error has gone I now I am able to connect to Oracle via PHP successfully
Here is a working solution:
- First, you need to find out if you use PHP x86 or x64. The easyest way is to use the folowing code:
<?php echo PHP_INT_SIZE; ?>
If you get 4
, it means you use PHP x86.
If you get 8
, it means you use PHP x64.
- Then, you need to download a version of Oracle which matches your PHP architecture: for example, download x86 version of Oracle if you use PHP x86. You can't mix version.
Version 11G:
Version 11g, Windows x64 : https://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html Download
Oracle Database 11g Release 2 ***Client*** (11.2.0.1.0) for Microsoft Windows (x64)
.Version 11g, Windows x86 : https://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win32soft-098987.html Download "
Oracle Database 11g Release 2 **Client** (11.2.0.1.0) for Microsoft Windows (32-bit)
".
Version 12C:
https://www.oracle.com/technetwork/database/enterprise-edition/downloads/oracle12c-windows-3633015.html Download either
Oracle Database 12c Release 2 Client (12.2.0.1.0) for Microsoft Windows (x64)
or Oracle Database 12c Release 2 Client (12.2.0.1.0) for Microsoft Windows (32-bit)
.
Install Oracle
Find out if you use PHP (TS) Threadsafe version or PHP (NTS) Non-Threadsafe Version. To do so, use the code:
<?php phpinfo(); ?>
Screenshot of phpinfo for TS version
Screenshot of phpinfo for NTS version
If in the value of Zend Extension Build
, you find TS
, you use the Threadsafe (TS) version of PHP.
If in the value of Zend Extension Build
, you find NTS
, you use the Non-Threadsafe (NTS) version of PHP.
- Download the latest version of the PHP OCI8 extensions DLL. To do so, go to https://pecl.php.net/package/oci8 and click the
DLL
link with the Windows icon in theDownloads
column corresponding to the version of the DLL you need.
For PHP version 5.3, 5.4, 5.5 and 5.6, the latest version is 2.0.12
.
For PHP 7.0, it's version 2.1.8
.
For PHP 7.1, 7.2, 7.3, it's version 2.2.0
.
Then, proceed to download the archive corresponding to your PHP version and architecture: if you use PHP 7.2 x86 TS, download the according file: 7.2 Thread Safe (TS) x86
Unzip the downloaded file, in the
ext
folder of your PHP installation. Replace old files with new ones.Enable the PHP OCI8 extension in your php.ini file.
If you installed Oracle 11g, you need to add the folowing line to your php.ini
file:
ext=php_oci8_11g.dll
If you installed Oracle 12c, you need to add the folowing line to your php.ini
file:
ext=php_oci8_12c.dll
NOTE: Only one of the 3 available PCP OCI8 extensions can be enabled at the same time. If you have multiple lines starting with ext=php_oci8
, check that only one is enabled. A disabled line start with a semi-colon. If you find more than one line, delete or comment (add a semi-colon at the begining of the line) the line.