So I had been trying to get PHP on a Debian system to talk to our Oracle database for a while, and it had been nagging me for long enough that I decided to post my solution here.
A bit of context:
I needed to get connectivity to our Oracle database on a Debian Etch x86_64
installation. Oracle provides the Oracle Instant Client (OCI), for which
PHP has support.
The Debian packages for PHP however were not compiled with OCI support,
but you can recompile your own and enable it:
- get the current OCI release (the patch below assumes you grab 11.1 which is currently the latest)
- unzip to /usr/local/OCI (if you use a different location you'll have to change the patch accordingly)
- set your LD_LIBRARY_PATH to /usr/local/OCI
- create some symlinks. I'm not 100% sure this is needed but I suppose it doesn't hurt
libclntsh.so -> libclntsh.so.11.1
libocci.so -> libocci.so.11.1
- get the php5 package source: apt-get source php5
- install all dependent packages: apt-get build-dep php5 (the Debian Developer Reference is a very useful resource)
- apply this patch to your tree. this is the core piece. you may have to tweak it depending on OCI version and install location. basically passing --with-oci8 to apache2 module config and setting appropriate version numbers
- rebuild packages: dpkg-buildpackage -rfakeroot
You will also need to add the LD_LIBRARY_PATH to your /etc/init.d/apache2 script so it finds the OCI libraries on startup.