Search code examples
phpwindowsoci8

OCI8 with PHP7 - module not found


I'm currently setting up a Windows 10 Pro x64 machine to work with Apache, PHP and its oci8 extension. I successfully managed to get oci8 working on OSX 10.11 and Windows 2012 Server before, so I thought I knew what to do. But this was 32bit – now it's 64.

The software now installed is:

  • Apache 2.4.18 x64
  • PHP 7.0.3 TS x64
  • Oracle Instant Client x64 (instantclient-basic-windows.x64-12.1.0.2.0)
  • oci8 2.1.0 TS x64

I don't get it to work. The error message is:

Warning: PHP Startup: Unable to load dynamic library 'ext\php_oci8_12c.dll' - Das angegebene Modul wurde nicht gefunden. (Module not found.)

in Unknown on line 0

Extension 'oci8' not present.

I installed the Oracle Instant Client by writing its directory into the PATH variable and copied the php_oci8_12c.dll file to the PHP ext dir and uncommented the corresponding line in the php.ini. Shouldn't that be enough?

I've read many postings here on Stackoverflow and other websites about similar problems, things I've tried:

  • Moving all DLLs to C:\Windows\system32
  • Include the PHP extension dir in the PATH variable
  • Re-checked that every component is 64bit
  • Created ORACLE_HOME and ORACLE_BASE variables (which shouldn't be necessary)

If I change the php_oci8_12c.dll x64 to the 32bit one, I get a different error message:

Warning: PHP Startup: Unable to load dynamic library 'ext\php_oci8_12c.dll' - %1 ist keine zulässige Win32-Anwendung. (%1 is not a valid Win32 program.)

in Unknown on line 0

Extension 'oci8' not present.

Any ideas what's wrong with all that?

Thank You!


Solution

  • To sum it all up,

    One more thing... NTS assumes that PHP does not run as Apache module, is that correct? Are you using FastCGI? – Álvaro González

    was the way to go. If anyone's having troubles with the same, here are the exact steps I took:

    • PHP 7.0.3 VC14 x64 Thread Safe from windows.php.net/download/
    • Apache 2.4.18 x64 from apachehaus.com/cgi-bin/download.plx
    • Oracle Instant Client 12.1.0.2.0 x64 from oracle.com/technetwork/topics/winx64soft-089540.html
    • (Get the current Thread Safe oci8 DLL from pecl.php.net/package/oci8, but PHP comes with a version of it - worked with either for me)

    Install PHP as an Apache module. Unzip the Instant Client and move it to your desired location. Add this location to your PATH system variable. Restart your machine and it should show up under 'PATH' in your phpinfo().

    Then I had to make the PHP extension_dir an absolute path. So no 'ext', but 'C:/Program Files/php-7.0.3/ext'. With only 'ext' set to the extension_dir I could connect to a remote Oracle DB via 'php.exe filename.php'. But Apache would throw me an error in error.log that it cannot find the DLL.

    No DLL copying is needed if you choose to keep the oci DLL that comes with PHP. No more environment variables than PATH have to be changed/created.

    At least in my case :-)