Oracle and PHP5 in Debian-like systems

This post helped me install Oracle XE on my developer machine successfully! It worked for my Debian Lenny system previously, and I’ve personally verified it to work with MEPIS 8.0, Ubuntu 9.04 and Linux Mint 7, Linux Mint 8 and Xubuntu 10.04.

1. Oracle Express Edition (XE)

This step is optional if you already have an Oracle server to use, but in my experience, it’s far better to have one setup locally.

Add the following repository to your apt sources:

deb unstable main non-free

Install Oracle XE:

wget -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install oracle-xe-universal

It’s a pretty big download (~260 MB). The installation, like most in Debian systems, is a breeze. When the installer completes there is one extra step:

sudo /etc/init.d/oracle-xe configure

You’ll be asked to create a system/sys (administrative user) password, and whether or not to start Oracle on boot.

2. Oracle Instant Client

You can skip this step if Step 1 was completed. The Instant Client is required if Oracle XE is unavailable.

Downloaded the RPMs from here. You’ll need the basic, devel packages for Linux. Once the download is complete, use alien to convert .rpm into .deb. I also converted it to deb using alien (which you may not have, but can install using ‘sudo apt-get install alien’, and then installed:

# If you have alien, skip the following line
sudo apt-get install alien

# Converting and installing RPMs
sudo alien oracle*.rpm
sudo dpkg -i oracle*.deb

3. oci8 Static Object (SO)

This step is required for Oracle/PHP to play nice.

# If php-pear, php5-dev are installed, skip the following line
sudo apt-get install php-pear php5-dev

# Compling the oci8 static object (SO)
sudo pecl install oci8

At some point during this process, you’ll be prompted to input $ORACLE_HOME. If you used Step 1, input “/usr/lib/oracle/xe/app/oracle/product/10.2.0/server”. If you used Step 2, input “instantclient,/usr/lib/oracle/11.2/client/lib”. The compilation takes awhile.

4. Loading

Save a new file as /etc/php5/conf.d/oci8.ini. Add the text “”, so that it becomes available everywhere.

5. Restart Apache

sudo /etc/init.d/apache2 restart

5 thoughts on “Oracle and PHP5 in Debian-like systems

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s