Enable OCI8 for PHP 5.4 on Mac OS X 10.9.x

The Tech Report
Political Parties and Digital Strategy
May 30, 2014
Finger Technology and Ecommerce Development
Fingerprint Technology And eCommerce Development
June 22, 2014
Show all

Enable OCI8 for PHP 5.4 on Mac OS X 10.9.x

Oracle - Oci 8

I have been using PHP with Oracle DB for sometime now, but recently after upgrading to Mac OS X 10.9, i’ve had to re-install the PHP library and reconfigure it. After many failed attempts to install OCI8, i have finally managed to get it working and thought i would share my findings.

Before i start, i do know of other issues related to OCI which may help get it running without reconfiguring PHP.

If you get the following error while trying to use oracle with PHP:

It could either mean that OCI8 is not enable or is not installed. To fix this, open your php.ini file and find the line:

Change it to:

Run your php script and check if it works. If it does not work, it means that you do not have OCI8 installed and configured for PHP and you are probably seeing the following error:

Install and configure OCI8 with PHP:

  1. Download the following Oracle client library files from ORACLE, making sure you download Version 11.2.0.4.0 (64-bit). You will need to have an Oracle user account and logged in to download the required files. If you do not have an account, create one, its free.
    • Basic: instantclient-basic-macos.x64-11.2.0.4.0.zip
    • SQLplus: instantclient-sqlplus-macos.x64-11.2.0.4.0.zip
    • SDK: instantclient-sdk-macos.x64-11.2.0.4.0.zip
  2. Once you have downloaded all 3 packages, open up terminal.
  3. Switch to root and create a working directory:
  4. Move the downloaded packages to your working directory ([DOWNLOAD LOCATION] = your download location):
  5. Extract:
  6. Copy the necessary files into your OS X dynamic library and bin directories:
  7. Add symbolic links required for setup:
  8. Test SQLplus:

    Should output:

    Press CTRL+C to quit SQLplus.
  9. The Oracle client should now be installed correctly and we can start installing OCI8.
  10. Check that you have PEAR installed:

    If its installed, you should get the following output or similar:

    If not, you will need to install PEAR in order to continue.
  11. Download and Install OCI8 PECL package:
  12. During the install, you will be prompted:

    Enter:
  13. Once the install is complete, open your php.ini file and add the following to the end of the file:
  14. Now all you need to do is restart apache and test your PHP script again. You can also check that OCI8 is installed running “php -i | grep oci” in terminal and check the output.

Thats it. If you do not have pear installed or cant get it installed, then you will need to install OCI8 manually by downloading OCI8 from PECL and compiling it with PHP 5.4.