Total Pageviews

Wednesday 4 July 2012

Oracle Database Instant Client and PHP OCI-8 connectivity


Download the Basic and the SDK Instant Client packages from the OTN Instant Client page.I have used RPMs:
Install the RPMs as the root user, for example:
rpm -Uvh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
rpm -Uvh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm

The first RPM puts Oracle libraries in /usr/lib/oracle/11.2/client64/lib and the second creates headers in /usr/include/oracle/11.2/client64.

Below is the log of the steps that i followed :


[root@sumit-rhel-5]# rpm -Uvh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
Preparing...                ########################################### [100%]
   1:oracle-instantclient11.########################################### [100%]
[root@sumit-rhel-5]# rpm -Uvh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
Preparing...                ########################################### [100%]
   1:oracle-instantclient11.########################################### [100%]
[root@sumit-rhel-5 oracle]# cd /usr/lib/oracle/11.2/client64/lib
[root@sumit-rhel-5 lib]# ls -l
total 182304
lrwxrwxrwx 1 root root        17 Jul  4 05:52 libclntsh.so -> libclntsh.so.11.1
-rw-r--r-- 1 root root  52761218 Sep 17  2011 libclntsh.so.11.1
-rw-r--r-- 1 root root   7955322 Sep 17  2011 libnnz11.so
lrwxrwxrwx 1 root root        15 Jul  4 05:52 libocci.so -> libocci.so.11.1
-rw-r--r-- 1 root root   1971762 Sep 17  2011 libocci.so.11.1
-rw-r--r-- 1 root root 118408281 Sep 17  2011 libociei.so
-rw-r--r-- 1 root root    164836 Sep 17  2011 libocijdbc11.so
-rw-r--r-- 1 root root   2095661 Sep 17  2011 ojdbc5.jar
-rw-r--r-- 1 root root   2714016 Sep 17  2011 ojdbc6.jar
-rw-r--r-- 1 root root    300666 Sep 17  2011 ottclasses.zip
-rw-r--r-- 1 root root     66779 Sep 17  2011 xstreams.jar
[root@sumit-rhel-5 lib]# cd /usr/include/oracle/11.2/client64
[root@sumit-rhel-5 client64]# ls -l
total 1672
-rw-r--r-- 1 root root  42534 Sep 17  2011 ldap.h
-rw-r--r-- 1 root root  34962 Sep 17  2011 nzerror.h
-rw-r--r-- 1 root root  74787 Sep 17  2011 nzt.h
-rw-r--r-- 1 root root  11586 Sep 17  2011 occiAQ.h
[root@sumit-rhel-5 oracle]# ls -l
total 58768
-rw-r--r-- 1 root   root   59492344 Jul  4 05:41 oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
-rw-rw-r-- 1 oracle oracle   609139 Jul  4 05:48 oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
drwxr-xr-x 2 root   root       4096 Jul  4 05:49 rpmoci
[root@sumit-rhel-5 oracle]#
[root@sumit-rhel-5 oracle]#
[root@sumit-rhel-5 oracle]# pecl install oci8
downloading oci8-1.4.7.tgz ...
Starting to download oci8-1.4.7.tgz (168,584 bytes)
.......................done: 168,584 bytes
10 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
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] : (Press Enter)
building in /var/tmp/pear-build-root/oci8-1.4.7
running: /var/tmp/oci8/configure --with-oci8
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ANSI C... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
.....................
cc -shared  .libs/oci8.o .libs/oci8_lob.o .libs/oci8_statement.o .libs/oci8_collection.o .libs/oci8_interface.o  -L/usr/lib/oracle/11.2/client64/lib -lclntsh  -Wl,-rpath -Wl,/usr/lib/oracle/11.2/client64/lib -Wl,-soname -Wl,oci8.so -o .libs/oci8.so
creating oci8.la
(cd .libs && rm -f oci8.la && ln -s ../oci8.la oci8.la)
/bin/sh /var/tmp/pear-build-root/oci8-1.4.7/libtool --mode=install cp ./oci8.la /var/tmp/pear-build-root/oci8-1.4.7/modules
cp ./.libs/oci8.so /var/tmp/pear-build-root/oci8-1.4.7/modules/oci8.so
cp ./.libs/oci8.lai /var/tmp/pear-build-root/oci8-1.4.7/modules/oci8.la
PATH="$PATH:/sbin" ldconfig -n /var/tmp/pear-build-root/oci8-1.4.7/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /var/tmp/pear-build-root/oci8-1.4.7/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-oci8-1.4.7" install
Installing shared extensions:     /var/tmp/pear-build-root/install-oci8-1.4.7/usr/lib64/php/modules/
running: find "/var/tmp/pear-build-root/install-oci8-1.4.7" | xargs ls -dils
196806   4 drwxr-xr-x 3 root root   4096 Jul  4 05:55 /var/tmp/pear-build-root/install-oci8-1.4.7
196810   4 drwxr-xr-x 3 root root   4096 Jul  4 05:55 /var/tmp/pear-build-root/install-oci8-1.4.7/usr
196811   4 drwxr-xr-x 3 root root   4096 Jul  4 05:55 /var/tmp/pear-build-root/install-oci8-1.4.7/usr/lib64
196812   4 drwxr-xr-x 3 root root   4096 Jul  4 05:55 /var/tmp/pear-build-root/install-oci8-1.4.7/usr/lib64/php
196813   4 drwxr-xr-x 2 root root   4096 Jul  4 05:55 /var/tmp/pear-build-root/install-oci8-1.4.7/usr/lib64/php/modules
720897 484 -rwxr-xr-x 1 root root 489488 Jul  4 05:55 /var/tmp/pear-build-root/install-oci8-1.4.7/usr/lib64/php/modules/oci8.so

Build process completed successfully
Installing '/usr/lib64/php/modules/oci8.so'
install ok: channel://pecl.php.net/oci8-1.4.7
configuration option "php_ini" is not set to php.ini location

You should add "extension=oci8.so" to php.ini

[root@sumit-rhel-5 modules]# vi /etc/sysconfig/httpd

# Configuration file for the httpd service.

#
# The default processing model (MPM) is the process-based
# 'prefork' model.  A thread-based model, 'worker', is also
# available, but does not work with some modules (such as PHP).
# The service must be stopped before changing this variable.
#
#HTTPD=/usr/sbin/httpd.worker

#
# To pass additional options (for instance, -D definitions) to the
# httpd binary at startup, set OPTIONS here.
#
#OPTIONS=

#
# By default, the httpd process is started in the C locale; to
# change the locale in which the server runs, the HTTPD_LANG
# variable can be set.
#
#HTTPD_LANG=C
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
~
"/etc/sysconfig/httpd" 24L, 674C written
[root@sumit-rhel-5 modules]#
[root@sumit-rhel-5 modules]#
[root@sumit-rhel-5 modules]#
[root@sumit-rhel-5 modules]#
[root@sumit-rhel-5 modules]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                               [  OK  ]
[root@sumit-rhel-5 modules]#


No comments:

Post a Comment