Get the OCI8 module working on a Mac require several settings. I wrote a script to automate the procedure that install and configure SqlPlus, the Oracle Client v10.2, Apache2, PHP5 and the OCI8 on a Mac OS X running Leopard. The script was tested on a Leopard 10.5.4 machine. I have never tested it on Tiger but I don’t recommend to test it there without having an idea of how to backup and restore all the Apache configuration files.
1. Download from the Oracle website the Oracle Client for Mac OS X (Intel x86) Version 10.2.0.4 and the SqlPlus:
– the Oracle Client ‘Instant Package – Basic’ [instantclient-basic-macosx-10.2.0.4.0.zip]
– the Oracle Client ‘Instant Package – SDK’ [instantclient-sdk-macosx-10.2.0.4.0.zip]
– the Oracle Client ‘Instant Package – SqlPlus‘ [instantclient-sqlplus-macosx-10.2.0.4.0.zip]
2. Download the bash script MacOracleViaPHP.sh. Last version can be found in the script page.
3. Download the last version of the following programs respecting the file format
– Apache2 [httpd-X.X.X.tar.gz]
– PHP5 [php-5.X.X.tar.gz]
– OCI8 [oci8-X.X.X.tgz]
1. Copy all these files in your Mac directory /var/root in the following way
– Create a folder on the desktop and move all the files in this folder
– Open the terminal
– If you don’t have a root password set you will need to set one
# sudo passwd
– Log in as root
# su –
– Copy the files inside the folder you created into the root directory /var/www
cp /Users/YOUR_MAC_USERNAME/Desktop/FOLDER_YOU_CREATED/* .
(don’t forget the dot ‘.’ at the end of the command)
– Check that the files are in the right place
# cd /var/root
2. Enter the home directory of the user root, change the permissions of the installation script and execute it.
# chmod 755 MacOracleViaPHP.sh
3. Type: Oracle SID, Oracle Server, Oracle Server Port, Oracle Database Username, Oracle Database Password.
1. To connect the Oracle DB via SqlPlus you can run the following command:
# sqlplus DB_USER/[email protected]//DB_SERVER:DB_PORT/DB_SID
2. To check that PHP can connect Oracle, opening the page http://localhost/info.php you could see the OCI8 module enabled, and opening the page http://localhost/test.php you could connect the Oracle DB.
Your comment, error reports and improvement requests are always welcome ;D