Showing posts with label oracle. Show all posts
Showing posts with label oracle. Show all posts

Monday, July 4, 2011

php support oci8 on windows

It is not enjoyable to use PHP + Oracle. But if we have to, we must setup our PHP to support oci8(I haven't tried pdo_oci yet since it is highly experimental). I'm using PHP 5.2.14 and Oracle Database 10g on Windows. My web server is Apache2.2. 

Firstly i simply uncomment this line in php.ini and thought it should do the work:

extension=php_oci8.dll

Unfortunately, after i restart Apache, it still doesn't work and i got this error message:
PHP Fatal error:  Uncaught exception 'Zend_Db_Adapter_Oracle_Exception' with message 'The OCI8 extension is required for this adapter but the extension is not loaded'

I found oracle's offcial instruction from http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html and start to follow it.

1. Download the "Instant Client Package - Basic" for Windows from the OTN Instant Client page. Because PHP is 32 bit, use the 32 bit version of Instant Client.

Unzip the Instant Client files to C:\instantclient_11_2

2. Edit the Windows PATH environment setting and add C:\instantclient_11_2

3. uncomment extension=php_oci8.dll

4. Restart Apache

However, it still doesn't work! 

Finally, i found someone with exact same problem with me. He sovled the problem by copying these three files from instantclient_11_2 to Apache/bin folder:

oraociei10.dll
orannzsbb10.dll
oci.dll

So i also copy them into Apache/bin and restart the Apache. This time, it works, finally. So my steps to enable PHP OCI8 on windows are:

1. Download the "Instant Client Package - Basic" for Windows from the OTN Instant Client page. Because PHP is 32 bit, use the 32 bit version of Instant Client.

Unzip the Instant Client files to C:\instantclient_11_2

2. Edit the Windows PATH environment setting and add C:\instantclient_11_2

3. Copy oraociei10.dll, orannzsbb10.dll, oci.dll from C:\instantclient_11_2 to Apache/bin

4. uncomment extension=php_oci8.dll in php.ini

5. restart Apache