skonsoft skonsoft - 2 years ago 307
PHP Question

How to install oracle instantclient and pdo_oci on ubuntu machine?

I need to install PDO_OCI in ubuntu machine, there is no default package that I could install with apt-get.

There are a lot of tutorials showing how to do it, but when I follow them, I have problems related to compilation (configure, make,...)

Here what I did:

  1. I followed this Tutorial to install instant client

  2. Install oci8

    pecl install oci8

    I get error:

    error: oci.h not found

  3. Install PDO_OCI

    mkdir -p /tmp/pear/download/
    cd /tmp/pear/download/
    pecl download pdo_oci
    ./configure –with-pdo-oci=instantclient,/usr,11.2


    pdo_driver.h not found ...

Please do you have any serious tutorial that works perfectly on UBUNTU 12.04?

Answer Source

The PDO, PDO_OCI extensions from pecl install are obsolete because latest PHP version has them built-in its core & installation these extensions by this way mostly failed.

I've spent a lot of time to try to do this following several approach with no luck, and finally find it out by myself a clean way to do this: compile & install the extensions from PHP source.

During the compilation, there are some tricks as well, I've described the process in detail in my personal blog:

Short steps are listed here:

  1. Download & install Oracle instant Client, then export ORACLE_HOME environment variable
  2. Download & compile PDO_OCI (and OCI8 if needed) form PHP source packages, there are some tricks that you need to applied here, including:

    sudo ln -s /usr/include/php5/ /usr/include/php

    and edit the Makefile:

    EXTRA_INCLUDES = -I/usr/include/oracle/11.2/client64

  3. Enable the extensions and restart web server

This has been tested for Debian 7.6 as well

Hope this helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download