Installing oci8 for PHP 5 on SuSE 10

Filling in where the internets failed me again, here are step-by-step instructions for getting oci8 extensions running in php without having to recompile anything.

Prerequisites

First, you will need to download some stuff and make sure you have certain packages installed:

Oracle Instant Client
I used version 10.2.0.3 cause I know it works.
http://www.oracle.com/technology/tech/oci/instantclient/index.html

Do not download the rpm version, it is much easier to use the zip version. Trust me, I’ve tried them both.
There are three files you should snag:
* Instant Client Package – Basic (instantclient-basic-linux32-10.2.0.3-20061115.zip)
* Instant Client Package – SQL*Plus (instantclient-sqlplus-linux32-10.2.0.3-20061115.zip)
* Instant Client Package – SDK (instantclient-sdk-linux32-10.2.0.3-20061115.zip)

oci8 PECL package
I used version 1.3.2. If you have problems, try version 1.3.0. (1.3.1 didn’t work for me)
http://pecl.php.net/package/oci8

You will be grabbing one file – oci8-1.3.2.tgz

Packages
Obviously, all the necessary components to have php5 with apache2 working. The default install should have everything you need, but just in case, the ones you might be missing are:
* php5-devel
* php5-pdo (maybe – not sure)
* php5-pear
* php5-pear-log
* something with which to unzip things
Also, if you are running suse 10, throw in for good measure:
* orarun
(creates oracle user, and a few other oracle friendly things)

Procedure Part 1 – Install Instant Client

Note: I did all this as root because the oracle user on my box doesn’t have interactive login, and I’m too lazy to fix it.

(If the directory “/opt/oracle” doesn’t exist, create it and make oracle:oinstall the owner)

ftp the four files into /opt/oracle

On the server:
> cd /opt/oracle

unzip the three Instant Client files. A new directory called instantclient_10_2 should have been created.

If you are root, make sure oracle owns everything:
> chown -R oracle:oinstall instantclient_10_2

Now you need to create the symbolic link for libclntsh.so -> libclntsh.so.10.1
> cd /opt/oracle/instantclient_10_2
> ln -s libclntsh.so.10.1 libclntsh.so
Again, if you are root, make oracle own the symlink
> chown -h oracle:oinstall libclntsh.so

Finally, to make sure that your libraries are found correctly at runtime, edit the file “/etc/ld.so.conf” (as root) and add the path to your instantclient install (/opt/oracle/instantclient_10_2) to the list of paths (add it on a new line before any include statements)

Save the file, then run (as root)
> /sbin/ldconfig

The Instant Client is ready to go!

Procedure Part 2 – Install oci8 PEAR extension

This part should be super easy! Do this as root:

> cd /opt/oracle
> pear5 install oci8-1.3.0.tgz
(That’s right, you don’t even have to untar the oci8 archive!)

At the prompt, enter:
instantclient,/opt/oracle/instantclient_10_2

There shouldn’t be any errors. If there are, it probably relates to missing packages.

Almost done!

The last step is to add the following line to php.ini, and reboot apache.
extension=oci8.so

On SuSE, you will need to edit two files /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini
I recommend adding the line after the comment block for “Dynamic Extensions”

reboot apache by running:
> apache2ctl -k stop
> apache2ctl -k start

Check to see if it worked. If apache doesn’t start, check your error logs(/var/log/apache2/error_log). You can always get apache running again by commenting out the line you added to php.ini.

4 thoughts on “Installing oci8 for PHP 5 on SuSE 10

  1. Jason, this is a really helpful article. Thanks for writing it. I’m curious though: I run this step and I get nothing but a returned command prompt, even though everything else appears to be set up properly. Any thoughts?

    $ pear5 install oci8-1.3.0.tgz
    (I do not get a prompt to enter instantclient or anything else.)

    Thanks,
    Christopher

  2. WOW! these are clear straight forward instructions. Imanaged to sovle the problem that had with getting php to work with oracle.

Leave a Reply

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