How to install PHP PDO_OCI on Ubuntu Jaunty

This is a revamped guide, previously wrote for gutsy, enjoy!

1) prerequisites

First of all we’ll install the php5-dev package which contains some utilities we’ll need for the build process:

sudo apt-get install php5-dev

then you’ve to find out your ORACLE_HOME environment variable, try executing:

env | grep ORACLE_HOME=

If this command outputs something like:


then you can jump to section “2) Getting and compiling PDO_OCI” otherwise go on thru this section.

If this guide we’ll just see how to find out which is your ORACLE_HOME directory if you’ve installed the oracle-xe server package. If you’ve installed instantclient or anything else please refer to the product documentation. So you’ve an installed and configured oracle-xe instance on your machine, now type:

cat /etc/init.d/oracle-xe |grep ORACLE_HOME=

the command should print something like:


now we’ve to export this variable to the current terminal session, we’ll do that with this command:

export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server

and the environment variable will be configured.

2) Getting and compiling PDO_OCI

Just cut and paste these simple commands to download PDO_OCI from the web and prepare it for the build phase:

cd /tmp
pecl download pdo_oci
tar xvfz PDO_OCI-1.0.tgz
cd PDO_OCI-1.0
mkdir include
ln -s /usr/include/php5/ include/php

now everything should be setup and we can build the driver and install it with:

make && make install

If everything is fine you can continue

3) Configuring PHP and Apache

if everything is fine you can go on editing your php.ini file and adding this line:

now create a phpinfo.php file under your apache’s document root, containing this line:

<?php phpinfo();

point your browser to:


and search for the “environment” section, it should look like the one in the next screenshot:
environment variables
if you see the ORACLE_HOME line everything it’s ok, jump to the “4) Closure” section otherwise edit /etc/apache2/envvars file and add the ORACLE_HOME configuration, it will be something like this (on a single line):

export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server

4) Closure

Restart your apache and you’re done:

sudo /etc/init.d/apache2 restart

One thought on “How to install PHP PDO_OCI on Ubuntu Jaunty

Leave a Reply

Your email address will not be published. Required fields are marked *