Install Oracle Express and PHP OCI8 on Ubuntu 9.10

Copiado del post de Daniel escrito en el marco de sus proyectos aqui : (Requirements: PHP 5 and Apache 2 already installed) Go to Oracle website, and download the following files: (You are gonna need to register an account with Oracle to be able to download the files, just do it, its free)
  1. oracle-xe-universal_10.2.0.1-1.0_i386.deb
  2. Oracle instant client basic, zip package
  3. Oracle instant client sdk, zip package
Install the first file with just double click. then go to console and run this command to configure it:
/etc/init.d/oracle-xe configure
you will see something like this:
Specify the HTTP port that will be used for Oracle Application Express [8080]:
Specify a port that will be used for the database listener [1521]:
Specify a password to be used for database accounts.  Note that the same
password will be used for SYS and SYSTEM.  Oracle recommends the use of
different passwords for each database account.  This can be done after
initial configuration:
Confirm the password:   (* make sure you remember this password *)

Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]: y
At this point you can open Firefox,enter, login as ’system’ with the ‘password’ you created during the install, and you should see the XE homepage. Now put the other 2 files in /tmp. Then do the following:
cd /tmp/
mv instantclient_11_2 /opt/
mv instantclient_11_2/sdk /opt/instantclient_11_2/
export ORACLE_HOME=/opt/instantclient_11_2/
ln -s /opt/instantclient_11_2/ /opt/instantclient_11_2//
ln -s /opt/instantclient_11_2/ /opt/instantclient_11_2//
ln -s /opt/instantclient_11_2/ /opt/instantclient_11_2/lib
then install the packages php-dev and php-pear, and go to console and type the following:
pecl download  OCI8
tar xzvf oci8-1.3.5.tgz

cd ../oci8-1.3.5
./configure --with-oci8=instantclient,/opt/instantclient_11_2/
sudo make install
At that point, the libraries have been built but are not used by PHP. In this extent, you must add it at the bottom of php.ini files “/etc/php5/apache2/php.ini” (and if you got CLI installed also add to this file “/etc/php5/cli/php.ini”):
extension =
Edit your /etc/bash.bashrc file to include the lines:

export PATH
Now just do a logout and login (this will restart the env variables, if you are advanced user then just do it your way). restart apache.Finally try this php example:
$ora_conn = oci_connect('system',$your_password,'');
// error handling
if (!$ora_conn){
// do the following if it fails
$ora_conn_erno = oci_error();
echo ($ora_conn_erno['message']."n");
} else {
// if it doesn't fail it will proceed with the rest of the script
echo "Connection Succesfuln";
If it shows “Connection Succesful” then you are done. Congratulations. Additional Notes:
  1. this was tested with PHP 5.2.10 ,Apache/2.2.12 and Ubuntu 9.10 Karmic Koala
  2. check that the ORACLE_HOME path exist just in case you have problems.
  3. if the version of instantclient you download is different to 11.2, just change every reference to 11_2 for your new version.