Search code examples
phpwindowsoracle-databaseserveroracle12c

Using php 7.3.4 64bit with a 64bit oracle client and php 7.3.4 32bit with a 32bit oracle client on the same server


We have an IIS on our Windows Server 2016 Standard which use via fast cgi a php 7.3.4 32bit.
To build a connection to a oracle 12cR1 database on another server we use the php_oci8_12c.dll and the oracle client 12.1.0 32bit.

This works fantastic. Now we want to switch to php 64bit, but for some old projects we still need the 32bit php and oracle client.

So we do the follow:
1. Uninstall the oracle client
2. Install oracle client 12.1.0 64 bit (install type: administration) in C:\Oracle\product\12.1.0\client_x64
3. Restart server
4. Configure the net manager
5. Install oracle client 12.1.0 32 bit (install type: administration) in C:\Oracle\product\12.1.0\client_x86
4. Restart server
5. Configure the net manager
6. Download php 7.3.4 64 bit with the 64 bit extensions

Now we have two php folders:
C:\php7_3_4_x86
C:\php7_3_4_x64

At this time the IIS use the C:\php7_3_4_x86\php-cgi.exe and the 32bit oracle client, because its the latest installed client and the path is the first of all paths in the PATH variable.

Now we want to switch temporary to 64bit. So we try the follow steps:
1. Change in IIS handler to C:\php7_3_4_x64\php-cgi.exe
2. Swap the oracle clients path in the environment variable PATH. Now its: C:\Oracle\product\12.1.0\client_x64;C:\Oracle\product\12.1.0\client_x86;[...]
3. Restart the server

After restart we try to open a php file in browser, but we get the follow error:
Call to undefined function oci_connect

If we put the oci.dll from C:\Oracle\product\12.1.0\client_x64\BIN directly into the C:\php7_3_4_x64 it loads the file. So we think it cannot find the 64bit client.

We also try the method with create a link in C:\Windows\system32 / SYSWOW64, but this doesnt work. Same error.

What could we do? We need the possibility to switch between 32&64bit php+oracle.


Solution

  • Problem solved.

    Everything was correctly, but the oracle setup forgot the correct windows right for the clientx64 folder.

    At the clientx86 the group "authenticated user" (in german: Authentifizierter Benutzer) has full access, while the clientx64 doesnt have this group.

    After adding the group and give it full access to the clientx64 folder it works. It isn't necessary to switch the entries in the PATH variable. PHP try to loading the first element and after failing it loads the second element in PATH variable.

    So everything works!