Wednesday, August 21, 2013

Setup OCI8 Extension for PHP by pecl php-pear with Oracle instant Client

1.Install php-pear pecl

# yum install php-pear gcc


2.Install oracle-instantclient-devel


# rpm -ivh oracle-instantclient-devel-10.2.0.5-1.i386.rpm


3.Compile PHP OCI8 Extension


# pecl install oci8
Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] : instantclient,/usr/lib/oracle/10.2.0.5/client/lib

running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-oci8-1.4.10" install
Installing shared extensions: /var/tmp/pear-build-root/install-oci8-1.4.10/usr/lib/php/modules/
running: find "/var/tmp/pear-build-root/install-oci8-1.4.10" -ls
4411004 4 drwxr-xr-x 3 root root 4096 Aug 22 04:10 /var/tmp/pear-build-root/install-oci8-1.4.10
4411033 4 drwxr-xr-x 3 root root 4096 Aug 22 04:10 /var/tmp/pear-build-root/install-oci8-1.4.10/usr
4411034 4 drwxr-xr-x 3 root root 4096 Aug 22 04:10 /var/tmp/pear-build-root/install-oci8-1.4.10/usr/lib
4411035 4 drwxr-xr-x 3 root root 4096 Aug 22 04:10 /var/tmp/pear-build-root/install-oci8-1.4.10/usr/lib/php
4411036 4 drwxr-xr-x 2 root root 4096 Aug 22 04:10 /var/tmp/pear-build-root/install-oci8-1.4.10/usr/lib/php/modules
4411032 408 -rwxr-xr-x 1 root root 412333 Aug 22 04:10 /var/tmp/pear-build-root/install-oci8-1.4.10/usr/lib/php/modules/oci8.so

Build process completed successfully
Installing '/var/tmp/pear-build-root/install-oci8-1.4.10//usr/lib/php/modules/oci8.so'
install ok: channel://pecl.php.net/oci8-1.4.10
You should add "extension=oci8.so" to php.ini


4.Create /etc/php.d/oci8.ini

; Enable OCI8 extension module
extension=oci8.so

[OCI8]

; Connection: Enables privileged connections using external
; credentials (OCI_SYSOPER, OCI_SYSDBA)
;oci8.privileged_connect = Off

; Connection: The maximum number of persistent OCI8 connections per
; process. Using -1 means no limit.
;oci8.max_persistent = -1

; Connection: The maximum number of seconds a process is allowed to
; maintain an idle persistent connection. Using -1 means idle
; persistent connections will be maintained forever.
;oci8.persistent_timeout = -1

; Connection: The number of seconds that must pass before issuing a
; ping during oci_pconnect() to check the connection validity. When
; set to 0, each oci_pconnect() will cause a ping. Using -1 disables
; pings completely.
;oci8.ping_interval = 60

; Connection: Set this to a user chosen connection class to be used
; for all pooled server requests with Oracle 11g Database Resident
; Connection Pooling (DRCP). To use DRCP, this value should be set to
; the same string for all web servers running the same application,
; the database pool must be configured, and the connection string must
; specify to use a pooled server.
;oci8.connection_class =

; High Availability: Using On lets PHP receive Fast Application
; Notification (FAN) events generated when a database node fails. The
; database must also be configured to post FAN events.
;oci8.events = Off

; Tuning: This option enables statement caching, and specifies how
; many statements to cache. Using 0 disables statement caching.
;oci8.statement_cache_size = 20

; Tuning: Enables statement prefetching and sets the default number of
; rows that will be fetched automatically after statement execution.
;oci8.default_prefetch = 100

; Compatibility. Using On means oci_close() will not close
; oci_connect() and oci_new_connect() connections.
;oci8.old_oci_close_semantics = Off

1 comment: