PHP and Oracle 10g on Debian

From a cached copy of the PHP.net website, posted by: mark at catalyst dot net dot nzed

ReCompiling PHP4 to have oracle 8 support (oci8) on Debian Linux, using the Oracle 10g client libraries. Log in as root.

PACKAGES REQUIRED:
apt-get install php4-dev
apt-get source -b php4 (Hit Ctrl-C once it has unpacked all the code)

apt-get install librecode-dev apache-dev apache2-prefork-dev chrpath debhelper freetds-dev po-debconf libbz2-dev libc-client-dev libcurl3-dev libdb4.2-dev libexpat1-dev libfreetype6-dev libgcrypt11-dev libgd2-xpm-dev libjpeg62-dev libkrb5-dev libldap2-dev libmcal0-dev libmhash-dev libmysqlclient12-dev libncurses5-dev libpam0g-dev libpcre3-dev libpng12-dev libsablot0-dev libsnmp5-dev libt1-dev libtool libwrap0-dev libxmltok1-dev libxml2-dev libxslt1-dev libzzip-dev re2c unixodbc-dev

OTHER PACKAGE REQUIREMENTS:
Oracle Client Libraries (i used Oracle 10g Server, but you should be able to use, as has been previously said, any set of the oracle client libraries from 8i onwards).
* make sure this is installed before recompiling php4.

ENVIRONMENT REQUIREMENTS:

– export ORACLE_HOME=[where u installed the oracle client]
– export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
– export LD_PRELOAD=libclntsh.so.10.1 (the version number at the end will correspond to the oracle version you previously installed. in my case, 10g is 10.1).
– vi /etc/ld.so.conf and add $ORACLE_HOME/lib to the list of paths.
then * run ldconfig to reload those changes to the system * (p.s. make sure it’s the full path, and not using any environment variables. e.g. /u01/app/oracle/product/10gRDBMS is my ORACLE_HOME).

STEPS:
– cd /usr/src/[PHP4 Version]
in my case, [PHP4 Version] = php4-4.3.8, so path was /usr/src/php4-4.3.10

– vi debian/rules
these are the default compilation rules for php4. Find section labeled COMMON_CONFIG = […] and add –with-oci8 (it should be near the top of the file).

debchange -i
– (allows you to edit the change log for the versions of php. btw – you should be in the php4 source code directory). give the version id something obviously unique. don’t forget to add a comment.

When all is in readyness, then you should be able to go debian/rules binary to build the debian packages required.
The .deb packages are built into the /usr/src directory. and depending on the default compilation options u choose, there should be a few. find the deb package that corresponds to the main php4 module (php4_4.3.8-4.mark.1_i386.deb for me), and run dpkg -i [package name] to install it.

To build:
cd /usr/src/php4-4.3.10
dpkg-buildpackage

– vi /etc/init.d/apache and add exports for $ORACLE_HOME, $LD_PRELOAD and $LD_LIBRARY_PATH

* don’t forget to restart apache /etc/init.d/apache to reload the php4 module. *

IF YOU GET… :
if you get an error saying something about apache cannot load libclntsh.so.10.1, file not found, check the environment variables, for both the user, and in /etc/init.d/apache and also check ld.so.conf to make sure the $ORACLE_HOME/lib path is in there, and has been reloaded (with ldconfig).

editing ld.so.conf was the part that finally got it working for me.
as you should be able to tell, the steps are pretty much the same as for all oracle versions 8i onwards, and all linux OS’s. but with a few debian specific paths and commands thrown in.

—-
Please note that I have made some changes based on a minimal Debian NetInst image… I had to add quite a few packages to get it all working.


Posted

in

by

Tags: