Oracle Instant Client and PHP OCI8 on Debian Squeeze

Because there is no deb package for PHP OCI8 for Debian, here is a simple tutorial how to install Oracle Instant Client and use PHP OCI8 on Debian Squeeze.

Install dependencies and required packages

This will install Apache with PHP5 support and all required packages to configure OCI8.


aptitude install php-pear php5-dev build-essential unzip libaio1

Download the software from Oracle website where you will need a Oracle account. You can create one for free if you don’t have one. Go to this link and choose your platform:

You need yo download the following packages:

Instant Client Package - Basic
Instant Client Package - SDK

Now we are going to create the location where we are going to store Oracle Instant Client files

mkdir -p /opt/oracle/instantclient
cd /opt/oracle/instantclient
mv instantclient_11_2/* ./
rm -r instantclient_11_2/

Now we need to create the missing simlinks

ln -s
ln -s

Now we are going to install the PHP part and OCI8 package

pecl install oci8 (when asked for ORACLE_HOME directory type: instantclient,/opt/oracle/instantclient)

At the and load OCI8 as extension and restart apache

echo "extension ="> /etc/php5/conf.d/oci8.ini
/etc/init.d/apache2 restart

You should now be able to see OCI8 as module in phpinfo() or type:

php-i | grep oci

you will get:

oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100 => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20

Also the easiest way i’ve found to connect to a remote Oracle database is with this code:

$c1 = oci_connect("name","password",$db);

I hope this will help you and here are some related links:

PHP OCI8 manual:
Oracle Database: