The world migration from 32-bit to 64-bit operating systems is gaining pace. However I’ve seen a couple of customers having difficulty with the PHP OCI8 extension and Oracle DB on Windows 64-bit platforms. The errors vary depending how PHP is run. They may appear in the Apache or PHP log:
Unable to load dynamic library 'C:\Program Files
(x86)\PHP\ext\php_oci8_11g.dll' - %1 is not a valid Win32
application.
or
Warning oci_connect(): OCIEnvNlsCreate() failed. There is
something wrong with your system - please check that PATH includes the
directory with Oracle Instant Client libraries
Other than IIS permission issues a common cause seems to be trying to use PHP with libraries from an Oracle 64-bit database on the same machine. There is currently no 64-bit version of PHP on http://php.net/ so there is a library mismatch.
A solution is to install Oracle Instant Client 32-bit and make sure that PHP uses these libraries, while not interferring with the 64-bit database on the same machine. Warning: The following hacky steps come untested from a Linux user:
- Unzip Oracle Instant Client 32-bit and move it to C:\WINDOWS\SYSWOW64\INSTANTCLIENT_11_2. You may need to do this in a console with elevated permissions.
- Edit your PATH environment variable and insert C:\WINDOWS\SYSTEM32\INSTANTCLIENT_11_2in the directory list before the entry for the Oracle Home library.
Windows makes it so all 32-bit applications that reference C:\WINDOWS\SYSTEM32 actually see the contents of the C:\WINDOWS\SYSWOW64 directory. Your 64-bit database won’t find an Instant Client in the real, physical C:\WINDOWS\SYSTEM32 directory and will continue to use the database libraries.
Some of our Windows team are concerned about this hack and prefer a more “correct” solution that (i) doesn’t require changing the Windows system directory (ii) doesn’t add to the “memory” burden about what was configured on the system (iii) works when there are multiple database versions installed. The solution is to write a script which will set the 64-bit (or 32-bit) Oracle libraries in the path as needed before invoking the relevant bit-ness application. This does have a weakness when the application is started as a service.
As a footnote: If you don’t have a local database and simply need to have 32-bit and 64-bit Instant Client accessible at the same time, try the “symbolic” link approach covered in the hack in this OTN forum thread.
Reminder warning: This blog post came untested from a Linux user.