Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save phpfour/e6591be370d7ad841ff7 to your computer and use it in GitHub Desktop.
Save phpfour/e6591be370d7ad841ff7 to your computer and use it in GitHub Desktop.
install Oracle PHP Extension (oracle OCI8) - instantclient for Mac OS 10.8

Installation

This procedure is tested on Mac OS X 10.8 with Developpers tools installed (xCode).

Preparation

Download the following files from Oracle website (yes, you need to create an account and accept terms):

Create and unzip all theses files into a the directory /usr/local/instantclient/11.2.0.3/.

This directory will looks like:

.
├── BASIC_README
├── SQLPLUS_README
├── adrci
├── genezi
├── glogin.sql
├── libclntsh.dylib.11.1
├── libnnz11.dylib
├── libocci.dylib.11.1
├── libociei.dylib
├── libocijdbc11.dylib
├── libsqlplus.dylib
├── libsqlplusic.dylib
├── ojdbc5.jar
├── ojdbc6.jar
├── sdk
│   ├── SDK_README
│   ├── demo
│   ├── include
│   ├── ott
│   └── ottclasses.zip
├── sqlplus
├── uidrvci
└── xstreams.jar

Create symlinks

   ln -s /usr/local/instantclient/11.2.0.3/sdk/include/*.h /usr/local/include/
   ln -s /usr/local/instantclient/11.2.0.3/sqlplus /usr/local/bin/
   ln -s /usr/local/instantclient/11.2.0.3/*.dylib /usr/local/lib/
   ln -s /usr/local/instantclient/11.2.0.3/*.dylib.11.1 /usr/local/lib/
   ln -s /usr/local/lib/libclntsh.dylib.11.1 /usr/local/lib/libclntsh.dylib

Test with sqlplus instantclient

I recommand to install Oracle Server with a VirtualBox VM preinstalled.

   /usr/local/bin/sqlplus oracle/[email protected]

Install extension with pecl

cd /usr/local/php5/bin
sudo pecl install oci8

If the script prompt you to provide the path to ORACLE_HOME directory, respond with:

instantclient,/usr/local/lib

And your are done, normally pecl will automatically load the extension in your php.ini. If not, add the following line to your php.ini:

extension=oci8.so

Restart your HTTP Server and test.

Enjoy (or try to...) !

@phpfour
Copy link
Author

phpfour commented Jan 22, 2016

Additional steps:

  1. sudo nano /System/Library/LaunchDaemons/org.apache.httpd.plist
  2. Add ORACLE_HOME, DYLD_LIBRARY_PATH, LD_LIBRARY_PATH into this plist. And then restart apache server.
<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
  <dict>
    <key>Disabled</key>
    <true/>
    <key>Label</key>
    <string>org.apache.httpd</string>
    <key>EnvironmentVariables</key>
    <dict>
      <key>XPC_SERVICES_UNAVAILABLE</key>
      <string>1</string>
      <key>ORACLE_HOME</key>
      <string>/usr/local/lib/oracle/instantclient_11_2</string>
      <key>DYLD_LIBRARY_PATH</key>
      <string>/usr/local/lib/oracle/instantclient_11_2</string>
      <key>LD_LIBRARY_PATH</key>
      <string>/usr/local/lib/oracle/instantclient_11_2</string>
    </dict>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/sbin/httpd</string>
      <string>-D</string>
      <string>FOREGROUND</string>
    </array>
    <key>OnDemand</key>
    <false/>
  </dict>

  </plist>

@ajaxray
Copy link

ajaxray commented Jan 8, 2017

For php 5.6 and earlier, use - sudo pecl install oci8-2.0.10
instead of sudo pecl install oci8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment