For instantclient on osx 10.6 64bit follow these steps:
download instant client libraries and sdk, write all this in a folder. Make sure you get a 64-bit library, if you are on a 64-bit machine, 32-bit will not work! - test with the first sqlplus
create it if it doesn't exist
sudo vi /etc/launchd.conf
and add the following to the file (with your own path!)
setenv DYLD_LIBRARY_PATH /usr/oracle_instantClient64
You need to reboot the system at this point so that launchd passes the path to apache to find the path or see if restarting the launch works, although I have the feeling that reboot your system anyway!
You must add "extension = oci8.so" in php.ini
sudo vi /etc/php.ini
If this file does not exist, copy the php.ini.default file
sudo cp /etc/php.ini.default /etc/php.ini
then add the specified extension, it will have a section with a lot of extensions down, put it somewhere somewhere
oci requires a symbolic link library, so
sudo ln -s $DYLD_LIBRARY_PATH/libclntsh.dylib.10.1 $DYLD_LIBRARY_PATH/libclntsh.dylib
There is also some wierd hard-coded library link in oracle binaries, so fix that
mkdir -p /b/227/rdbms/
He is only looking for oracle libraries, so link it
ln -s /usr/oracle_instantClient64/ /b/227/rdbms/lib
now install oci8 from the pear repository. If you installed the osx 10.6 snow leopard without an update, you may have problems with the pear and club. If so, you need to install the pear first. see https://discussions.apple.com/thread/2602597?start=0&tstart=0
sudo pecl install oci8
TIP: do not use autodetect, specify the instantclient path when it asks you.
instantclient,/usr/oracle_instantClient64
restart apache
sudo apachectl graceful
by going to the URL in the browser or you can call the file directly on the command line
php index.php
thats it use the following as a test file.
<?php $dbHost = "localhostOrDatabaseURL"; $dbHostPort="1521"; $dbServiceName = "servicename"; $usr = "username"; $pswd = "password"; $dbConnStr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=".$dbHost.")(PORT=".$dbHostPort.")) (CONNECT_DATA=(SERVICE_NAME=".$dbServiceName.")))"; if(!$dbConn = oci_connect($usr,$pswd,$dbConnStr)){ $err = oci_error(); trigger_error('Could not establish a connection: ' . $err['message'], E_USER_ERROR); }; $strSQL = "SELECT SYSDATE FROM DUAL"; $stmt = oci_parse($dbConn,$strSQL); if ( ! oci_execute($stmt) ){ $err = oci_error($stmt); trigger_error('Query failed: ' . $err['message'], E_USER_ERROR); }; while(oci_fetch($stmt)){ $rslt = oci_result($stmt, 1); print "<h3>query returned: ".$rslt."</h3>"; } ?>