Monday, October 18, 2010

Adding oci8 support to php on linux (RHEL5 64-bit)

This is a fishing blog, but I feel compelled to post a solution to a computer problem I had a great deal of difficulty with.

Here are my notes on how I got php's oci8 extension compiled and working on Red Hat 5 64-bit.

Plain text notes here.

On RHEL5 (64-bit) using php 5.1.6-27

Downloaded the instantclient
instantclient-basic-linux-x86-64-11.2.0.2.0.zip

from
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Created diredtory /usr/lib/oracle/instantclient

Unzipped the instantclient zip file, added the instant client files into new dir called "lib":


[root@servername lib]# pwd
/usr/lib/oracle/instantclient/lib
[root@servername lib]# ls -al
total 178772
drwxr-xr-x 3 root root 4096 Oct 18 14:18 .
drwxr-xr-x 3 root root 4096 Oct 18 14:18 ..
-rwxr-xr-x 1 root root 25532 Oct 18 14:12 adrci
-rw-r--r-- 1 root root 439 Oct 18 14:12 BASIC_README
-rwxr-xr-x 1 root root 46352 Oct 18 14:12 genezi
lrwxrwxrwx 1 root root 17 Oct 18 14:13 libclntsh.so -> libclntsh.so.11.1
-rwxr-xr-x 1 root root 52439406 Oct 18 14:12 libclntsh.so.11.1
-r-xr-xr-x 1 root root 7898628 Oct 18 14:12 libnnz11.so
-rwxr-xr-x 1 root root 1972824 Oct 18 14:12 libocci.so.11.1
-rwxr-xr-x 1 root root 115820762 Oct 18 14:12 libociei.so
-r-xr-xr-x 1 root root 164756 Oct 18 14:12 libocijdbc11.so
-r--r--r-- 1 root root 2030135 Oct 18 14:12 ojdbc5.jar
-r--r--r-- 1 root root 2152051 Oct 18 14:12 ojdbc6.jar
drwxr-xr-x 4 root root 4096 Oct 18 14:12 sdk
-rwxr-xr-x 1 root root 192341 Oct 18 14:12 uidrvci
-rw-r--r-- 1 root root 66783 Oct 18 14:12 xstreams.jar

Added symlink in "lib" directory: libclntsh.so -> libclntsh.so.11.1

Then downloaded the sdk files:

instantclient-sdk-linux-x86-64-11.2.0.2.0.zip

Copied them into the lib directory in a dir called "sdk":


[root@servername sdk]# pwd
/usr/lib/oracle/instantclient/lib/sdk
[root@servername sdk]# ls -al
total 320
drwxr-xr-x 4 root root 4096 Oct 18 14:12 .
drwxr-xr-x 3 root root 4096 Oct 18 14:18 ..
drwxr-xr-x 2 root root 4096 Oct 18 14:12 demo
drwxr-xr-x 2 root root 4096 Oct 18 14:12 include
-r-xr-xr-x 1 root root 869 Oct 18 14:12 ott
-rw-r--r-- 1 root root 298394 Oct 18 14:12 ottclasses.zip
-rw-r--r-- 1 root root 435 Oct 18 14:12 SDK_README

Then, from /usr/local/src I ran:

pecl install oci8


And when prompted, I entered:

instantclient,/usr/lib/oracle/instantclient/lib
or
instantclient,/usr/lib/oracle/instantclient

(I can't remember exactly which one)

Compiling worked, now with the oci8 extension compiled and copied to the proper directory (in my case: /usr/lib64/php/modules/)

I added a file called "oci8.ini" to /etc/php.d which contains:

extension=oci8.so

Then I run "/etc/init.d/httpd restart"

And then phpinfo() displays:

oci8
OCI8 Support enabled
Version 1.4.3
Revision $Revision: 300752 $
Active Persistent Connections 0
Active Connections 0
Oracle Instant Client Version 11.2
Temporary Lob support enabled
Collections support enabled

Until the "lib" and "sdk" directories were located in the proper place I got errors such as:

"Instant Client SDK header files not found"

and

"Oracle Instant Client libraries not found"

I hope this helps someone down the line.

1 comment: