List Info

Thread: using pear built oci8 module to connect to oracle via apache2




using pear built oci8 module to connect to oracle via apache2
user name
2007-04-03 13:27:49
ok, for grins i decided to try and get the php oci8
extension to build
and load via pear/pecl. seems to go ok, here is a mini
how-to all done
with openSuSE 10.2 (x86_64 in this case). with both instant
client and
regular oracle client. i like this approach, i can keep the
default rpm
php install for the most part. first, instant client
(standard client will have
to wait a bit for my notes):


1. install needed php/pear rpms:

rpm -qa | grep php
php5-5.2.0-12
apache2-mod_php5-5.2.0-12
php5-pdo-5.2.0-10
php5-devel-5.2.0-12
php5-pear-5.2.0-12

2. install oracle instant client zips:

unzip
/tmp/instantclient-basic-linux-x86-64-10.2.0.3-20070103.zip
unzip
/tmp/instantclient-sdk-linux-x86-64-10.2.0.3-20070103.zip

3. make softlink for libclntsh.so.10.1

pwd
/opt/instantclient_10_2
ls -l
total 99900
-r--r--r-- 1 root root  1600090 2006-12-20 10:35
classes12.jar
-rwxr-xr-x 1 root root    66545 2006-12-20 10:35 genezi
lrwxrwxrwx 1 root root       17 2007-04-03 12:11
libclntsh.so -> libclntsh.so.10.1
-rwxr-xr-x 1 root root 20870419 2006-12-20 10:35
libclntsh.so.10.1
-rwxr-xr-x 1 root root  3808761 2006-12-20 10:35
libnnz10.so
-rwxr-xr-x 1 root root  1664148 2006-12-20 10:35
libocci.so.10.1
-rwxr-xr-x 1 root root 72456247 2006-12-20 10:35
libociei.so
-rwxr-xr-x 1 root root   137905 2006-12-20 10:35
libocijdbc10.so
-r--r--r-- 1 root root  1545954 2006-12-20 10:35
ojdbc14.jar
drwxr-xr-x 4 root root     4096 2006-12-20 10:35 sdk


4. build/install/enable oci8 module:

pear5 install http://pecl.php.net/get/
oci8

downloading oci8-1.2.3.tgz ...
Starting to download oci8-1.2.3.tgz (83,591 bytes)
....................done: 83,591 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 ORACLE_HOME dir. Use
'instantclient,/path/to/instant/client/lib' if you're
compiling against Oracle Instant Client [autodetect] :
instantclient,/opt/instantclient_10_2
building in /var/tmp/pear-build-root/oci8-1.2.3
running: /tmp/pear/cache/oci8-1.2.3/configure
--with-oci8=instantclient,/opt/instantclient_10_2
checking for grep that handles long lines and -e...
/usr/bin/grep

.......

/bin/sh /var/tmp/pear-build-root/oci8-1.2.3/libtool
--mode=install cp ./oci8.la
/var/tmp/pear-build-root/oci8-1.2.3/modules
cp ./.libs/oci8.so
/var/tmp/pear-build-root/oci8-1.2.3/modules/oci8.so
cp ./.libs/oci8.lai
/var/tmp/pear-build-root/oci8-1.2.3/modules/oci8.la
PATH="$PATH:/sbin" ldconfig -n
/var/tmp/pear-build-root/oci8-1.2.3/modules
------------------------------------------------------------
----------
Libraries have been installed in:
   /var/tmp/pear-build-root/oci8-1.2.3/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.
(It is safe to ignore warnings about tempnam and tmpnam).

running: make
INSTALL_ROOT="/var/tmp/pear-build-root/install-oci8-1.2
.3" install
Installing shared extensions:    
/var/tmp/pear-build-root/install-oci8-1.2.3/usr/lib64/php5/e
xtensions/running: find
"/var/tmp/pear-build-root/install-oci8-1.2.3" -ls
901127    4 drwxr-xr-x   3 root     root         4096 Apr  3
13:59 /var/tmp/pear-build-root/install-oci8-1.2.3
901156    4 drwxr-xr-x   3 root     root         4096 Apr  3
13:59 /var/tmp/pear-build-root/install-oci8-1.2.3/usr
901157    4 drwxr-xr-x   3 root     root         4096 Apr  3
13:59 /var/tmp/pear-build-root/install-oci8-1.2.3/usr/lib64
901158    4 drwxr-xr-x   3 root     root         4096 Apr  3
13:59
/var/tmp/pear-build-root/install-oci8-1.2.3/usr/lib64/php5
901159    4 drwxr-xr-x   2 root     root         4096 Apr  3
13:59
/var/tmp/pear-build-root/install-oci8-1.2.3/usr/lib64/php5/e
xtensionsld process completed successfully
Installing
'/var/tmp/pear-build-root/install-oci8-1.2.3//usr/lib64/php5
/extensions/oci8.so'
install ok: channel://pecl.php.net/oci8-1.2.3
You should add "extension=oci8.so" to php.ini

i added this to php.ini:

grep oci8 /etc/php5/apache2/php.ini
extension=oci8.so

and

grep oci8 /etc/php5/cli/php.ini
extension=oci8.so


where:

ls -l /usr/lib64/php5/extensions/oci8.so
-rwxr-xr-x 1 root root 353503 2007-04-03 13:59
/usr/lib64/php5/extensions/oci8.so
oci8.so


5. set LD_LIBRARY_PATH to the instant client directory for
apache and restart
apache2 and verify oci8 is enabled with a phpinfo script:

php phpinfo.php

oci8

OCI8 Support => enabled
Version => 1.2.3
Revision => $Revision: 1.269.2.16.2.29 $
Active Persistent Connections => 0
Active Connections => 0
Oracle Instant Client Version => 10.2
Temporary Lob support => enabled
Collections support => enabled

Directive => Local Value => Master Value
oci8.default_prefetch => 10 => 10
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => 0 => 0
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20

6: verify connection to remote 10g2 db:

 more phpdb2.php
<?php

$conn = OCILogon("dbuser", "dbpasswd",
"//dbserver.host.net/DB");

$query = 'select table_name from user_tables';

$stid = OCIParse($conn, $query);
OCIExecute($stid, OCI_DEFAULT);
 while ($succ = OCIFetchInto($stid, $row)) {
    foreach ($row as $item) {
      echo $item." ";
    }
    echo "<br>n";
 }

 OCILogoff($conn);

 ?>


php phpdb2.php
FMATING <br>
ZEROMAZE <br>
FPARTS <br>

....

done .....

works for me!

-- 
To unsubscribe, email: suse-oracle-unsubscribesuse.com
For additional commands, email: suse-oracle-helpsuse.com
Please see http://www.suse.com/oracl
e/ before posting


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )