Configuring PHP with ORACLE 8i Support
Ismail YENIGUL <ismail@EnderUNIX.ORG>

In This article i will briefly describe how to compile PHP with ORACLE  8i support

when i try to compile php with oracle support on Solaris 2.6 i got lots of problems. after tedious search in internet i have found  solution. I have following configuration:

* ORACLE 8.1.6
* PHP 4.0.6
* Apache 1.3.19(Already Installed)

Firstly  unpack php as  root 

#tar zxvf php-4.0.6.tar.gz
#cd php-4.0.6

Because  apache is already installed.  I want PHP to run as a  dynamic  Apache module.  I ran the configure script as follows

./configure  --with-apxs=/www/bin/apxs --enable-track-vars --with-oci8=/u01/app/oracle/product/8.1.6  \ --with-oracle=/u01/app/oracle/product/8.1.6 

This tells the configure script to build PHP as a shared Apache module and support for ORACLE. If your apxs  path is different then /www/bin/apxs, replace  /www/bin/apxs  with your apxs path. also  /u01/app/oracle/product/8.1.6  is my $ORACLE_HOME path. if your $ORACLE_PATH is different replace /u01/app/oracle/product/8.1.6  with your $ORACLE_HOME path.

The first time I ran the configure script it has given  following error.

checking for Oracle-OCI8 support... yes
checking Oracle Install-Dir... /u01/app/oracle/product/8.1.6/
+--------------------------------------------------------------------+
| Notice: |
| If you encounter <defunc> processes when using a local Oracle-DB |
| please recompile PHP and specify --enable-sigchild when configuring|
| (This problem has been reported un Linux using Oracle >= 8.1.5) |
+--------------------------------------------------------------------+
checking Oracle version... 7.3
configure: error: Unsupported Oracle version!

after adding  --enable-sigchild parameter.

./configure --with-oci8=/u01/app/oracle/product/8.1.6 --with-apxs=/www/bin/apxs --enable-track-vars  --with-oracle=/u01/app/oracle/product/8.1.6  --enable-sigchild

and then.

checking for Oracle-OCI8 support... yes
checking Oracle Install-Dir... /u01/app/oracle/product/8.1.6/
checking Oracle version... 7.3
configure: error: Unsupported Oracle version!

It gives   above error.

after searching in internet  i found that there is a bug in  php-4.0.6/configure file. I've to clarify here that this bug is not due to the  php package but ONLY due to Oracle changes after version 8.1.5.

Oracle decided to change the "orainst" directory name since version 8.1.5 to "install" in the $ORACLE_HOME directory. Therefore the script cannot open the file called "unix.rgs" there !  Configure script can not find oracle version so it returns always   7.3 as ORACLE_VERSION.

SOLUTION:

 In  php-4.0.6/configure file   comment out (#) lines between 34050 - 34068. and then write manually ORACLE_VERSION=8.1 to line 34070 

#echo $ac_n "checking Oracle version""... $ac_c" 1>&6 (34050. line)
#echo "configure:34052: checking Oracle version" >&5
#if test -s "$ORACLE_DIR/orainst/unix.rgs"; then
#ORACLE_VERSION=`grep '"ocommon"' $ORACLE_DIR/orainst/unix.rgs | sed 's/ */:/g' | cut -d: -f 6 | cut -c 2-4`
#test -z "$ORACLE_VERSION" && ORACLE_VERSION=7.3
#elif test -f $ORACLE_DIR/lib/libclntsh.s?.8.0; then
#ORACLE_VERSION=8.1
#elif test -f $ORACLE_DIR/lib/libclntsh.s?.1.0; then
#ORACLE_VERSION=8.0
#elif test -f $ORACLE_DIR/lib/libclntsh.a; then
#if test -f $ORACLE_DIR/lib/libcore4.a; then
#ORACLE_VERSION=8.0
#else
#ORACLE_VERSION=8.1
#fi
#else
#{ echo "configure: error: Oracle needed libraries not found" 1>&2; exit 1; }
#fi
 #echo "$ac_t""$ORACLE_VERSION" 1>&6 (34068.line )

ORACLE_VERSION=8.1 #(34070. line)

and also comment out lines between 31537 - 31555  and then write manually ORACLE_VERSION=8.1  to line 31556 

# echo $ac_n "checking Oracle version""... $ac_c" 1>&6 (31537. line)
#echo "configure:31539: checking Oracle version" >&5
# if test -s "$OCI8_DIR/orainst/unix.rgs"; then
# OCI8_VERSION=`grep '"ocommon"' $OCI8_DIR/orainst/unix.rgs | sed 's/ */:/g' | cut -d: -f 6 | cut -c 2-4`
# test -z "$OCI8_VERSION" && OCI8_VERSION=7.3
# elif test -f $OCI8_DIR/lib/libclntsh.s?.8.0; then
# OCI8_VERSION=8.1
# elif test -f $OCI8_DIR/lib/libclntsh.s?.1.0; then
# OCI8_VERSION=8.0
# elif test -f $OCI8_DIR/lib/libclntsh.a; then
# if test -f $OCI8_DIR/lib/libcore4.a; then
# OCI8_VERSION=8.0
# else
# OCI8_VERSION=8.1
# fi
#else
# { echo "configure: error: Oracle-OCI8 needed libraries not found" 1>&2; exit 1; }
# fi
# echo "$ac_t""$OCI8_VERSION" 1>&6

OCI8_VERSION=8.1 #(3156. line)

and finally  issue following  command to  finish 

#make clean 
#./configure --with-oci8=/u01/app/oracle/product/8.1.6 --with-apxs=/www/bin/apxs --enable-track-vars        --with-oracle=/u01/app/oracle/product/8.1.6  --enable-sigchild
#make
#make install

after adding  following lines to httpd.conf  file

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

and  before restart apache, apache must be told where ORACLE LIB directory is.  To accomplish this 

#export $LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/u01/app/oracle/product/8.1.6/lib

if your oracle lib dir is different than   /u01/app/oracle/product/8.1.6/lib change this with your $ORACLE_HOME/lib 
and restart Apache by issuing the apachectl restart command.

Ismail YENIGUL <ismail@EnderUNIX.ORG>
EnderUNIX Software Development Team Member