For this tutorial is based on Oracle Instant Client 11.2. Please note for correct install, we must use 64-bit version.
Download Instant Client from Oracle site(http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html): - Basic 64-bit - SDK 64-bit - SqlPlus 64-bit
Create the directory /opt/instantclient_11_2
mkdir -p /opt/instantclient_11_2
Uncompress instant client modules inside directory
tar -zxvf <file.tar>
The next step is to copy the necessary files into your OS X dynamic library and bin directories (as described here). Open a terminal window and go to the directory above the one you created containing all the files you unzipped.
sudo cp instantclient_11_2/sdk/include/*.h /usr/include
sudo cp instantclient_11_2/sqlplus /usr/bin
sudo cp instantclient_11_2/*.dylib /usr/lib
sudo cp instantclient_11_2/*.dylib.* /usr/lib
Now move to the /usr/lib directory and create the following link:
sudo ln -s libclntsh.dylib.11.1 libclntsh.dylib
To test, open another terminal window or tab, and try to run Oracle's SQLPlus tool using /usr/bin/sqlplus. If it worked, you are almost there. Exit SQLPlus by entering quit or simply Ctrl+C.
Download OCI8 module using pecl
pecl download oci8-2.0.8
Uncompress OCI8
tar -zxvf oci8-2.0.8.tar
Go to oci8 directory
cd oci8
Run configure to generate configuration rules to compilation
phpize
./configure --with-oci8=shared,instantclient,/usr/lib/
Run make to compile and install oci8.so - sudo make all install Open php.ini and add the following line:
extension=oci8.so
Restart apache.
<?php
$conn = oci_connect("username", "password", "//hostname/servicename");
if (!$conn) {
$m = oci_error();
echo $m['message'], "\n";
exit;
}
else {
print "Connected to Oracle!";
}
// Close the Oracle connection
oci_close($conn);
?>