Here is what I had to do in order to get Oracle support compiled into php.
1. Download and install Oracle 8i for linux.
You have to install the whole thing, not just the client stuff.
2. Download the latest php3 (or php4) source code.
3. Figure out what configuration flags you want to set.
I used the following for php 4:
./configure --with-apxs=/usr/sbin/apxs \
--prefix=/usr \
--with-gd \
--enable-versioning \
--with-mysql=/usr \
--with-oracle=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5 \
--with-oci8=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5 \
--with-zlib \
--with-dbase \
--with-filepro \
--with-config-file-path=/etc/httpd/conf \
--with-fdftk=no \
--enable-debug=no \
--enable-magic-quotes \
--enable-debugger \
--enable-bcmath \
--enable-track-vars \
--enable-safe-mode \
--with-exec-dir=/usr/bin \
--with-system-regex \
--no-create \
--no-recursion
I took most of these compile options from a mod_php src rpm. The --with-oracle directive enables
php to talk to Oracle 7.x and 8.x servers with the ORA functions. The --with-oci8 enables php to use
the more robust oci8 interface.
7. fix httpd.conf (I had to do this for Linux-Mandrake 6.1)
Change the line that says something like
LoadModule php4_module lib/apache/libphp4.so
to
LoadModule php4_module /usr/lib/apache/libphp4.so
8. Edit your php.ini file to re-enable sendmail support.(if you use mail() )
Add the path to sendmail to the "sendmail_path" line like:
sendmail_path = /usr/sbin/sendmail -t
You only have to do the above for php4, it can be left blank for php3
9. Restart apache
10. Test your php4 instalation.
Create a script with <? phpinfo(); ?> in it to find out what your php4 setup has built into it.
Make sure that it says something about Oracle and OCI8.
11. Try to use your new functionallity.
<?
// set some Oracle specific environment variables
putenv("ORACLE_SID=PROD");
putenv("ORACLE_HOME=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5");
// Let's make a connection
// Replace user_id, password and db with your own settings
if($conn = OCILogon("user_id","password","db"))
{
// Get some info about the db
printf("%s</P>", OCIServerVersion($conn));
}
else
{
printf("Conncetion Failed");
}
?>
it should print some info about the Oracle server that you connected to.
12. Other Stuff to do
If you are connecting to a remote Oracle server you will need to setup your sqlnet.ora and
tnsnames.ora files to point to the location of the remote db. Talk to the Oracle server's DBA to get
a copy of the files and place them in your
$ORACLE_HOME/network/admin/ directory.