Oracle can be a real pain to get installed on your server, however, since they’ve created a Debian (Sarge and later) repository it is a lot easier. Getting it to work with PHP (in this case version 5) will be another story which this small how-to will describe.
First, add the Debian repository to your /etc/apt/sources.list by adding the following two lines at the bottom of the file;
# Oracle XE deb http://oss.oracle.com/debian unstable main non-free
Afterwards run the following chain of commands as root;
wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | apt-key add - apt-get update apt-get install oracle-xe
Now Oracle is installed on your system and it will ask you to run /etc/init.d/oracle configure first.
Since this was the easy part let’s continue to the hard part; enabling Oracle in PHP.
First download the basic instantclient and the instantclient SDK zip files from www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html.
Create a directory in /usr/lib/oracle/xe/app/oracle/product/10.2.0 and name it instantclient.
Unzip the contents of the basic instantclient here and create another directory named sdk, in this one you should unzip the instantclient SDK.
When done, use the following commands:
cd /usr/lib/oracle/xe/app/oracle/product/10.2.0/instantclient ln -s libclntsh.so.10.1 libclntsh.so ln -s libocci.so.10.1 libocci.so
Now grab the following packages from the apt repository;
apt-get install php-pear apt-get install php5-dev
Oh yes, almost there! Create the oci8 module using pecl using the command pecl install oci8 and wait till it asks for the location of the instantclient. Then supply the following command instantclient,/usr/lib/oracle/xe/app/oracle/product/10.2.0/instantclient
hit <enter> and wait yet again till it finishes building the oci8.so file. When ready, edit php.ini and add extension=oci8.so to the dynamic extension block, reload Apache and enjoy your Oracle PHP installation!
As a last step you may wish to run apt-get clean so the Oracle Debian package will be cleared from the system, it’s a pretty big package after all!
If you want to access the web interface remotely (and) in a safe way; you can configure PuTTY to tunnel the connection for you.
Create a new session and give it a name, e.g. !apex. Go to Connection > SSH > Tunnels and add a new forwarded port; use 8888 for the source port and 127.0.0.1:8080 as the destination (or any other destination port depending on your configuration). Click add, save your session and login to the box. Change the proxy settings of your browser to localhost:8888 and make sure it’ll use this for internal addresses to. Open up a web page to http://127.0.0.1:8080/apex/ and you should be asked to login.
January 18th, 2008 on 11:01
Hi,
thanks for this good guide.
I just want to add the following detail:
to use the tnsnames.ora You have to put it in the following directory:
/usr/lib/oracle/xe/app/oracle/product/10.2.0/instantclient/network/admin/
CU
Jens
July 26th, 2008 on 20:40
Thanks Man!
My congratulations!
you have the simplest way ever to make this things work together
I’ve been running through several similar posts.. your’s made me truly Happy, Cheers!
October 9th, 2008 on 20:52
thanks for the guide – this helped immensely and finally put together a bunch of pieces I had been missing.
A note though for us newbies: look at your apache error logs for problems. I ran into the issue of not having libaio installed (sudo apt-get install libaio1) and this prevented php5 from using the oci8.so module.
October 21st, 2008 on 07:43
Many thanks for your nice guide, it prevented me from compiling PHP to get OCI8 for Oracle running (AND to explain my boss how to compile).
–
(Jeff: here oracle-xe seems to correctly depend on libaio, so that its installed automagically.)
December 11th, 2008 on 08:49
Hello Piro,
Thanks for this. Your instructions worked! I had the Oracle 11g DVD with me, and it didn’t work on my Debian Etch installation.
Thanks alot for sharing!
February 21st, 2009 on 23:02
You’re very welcome!
March 19th, 2009 on 03:52
I’ve added a post wrt Oracle, PHP, MEPIS:
http://waynekhan.com/blog/2009/03/oracle-and-php5-in-mepis/
Referencing this excellent post, of course!