Installing oracle on PHP 5.3.x on ubuntu
As a reminder, here is my setup:
- Windows 7 x64 host
- Ubuntu something VM using VirtualBox
- PHP 5.3.2 (but .x is fine) with apache2
First, I started by download the Oracle 10g express client: http://www.oracle.com/technetwork/database/express-edition/downloads/102xewinsoft-090667.html. Besides the horrible registration process (I mean, 7 tries to get an accepted password ? that can't be right), it went okay. Then I moved to the tricky part: getting the oci8 extension running on my VM's PHP.
First, you need the oci8 instantclient libraries. Two of them, to be accurate, from this page, in my case: http://www.oracle.com/technetwork/topics/linuxsoft-082809.html. Note, I was told the 11.x InstantClient files would work with oracle 10g XE. We'll see :-)
- instantclient-basiclite-linux32-11.2.0.2.0.zip
- instantclient-sdk-linux32-11.2.0.2.0.zip (these are the SDK files)
Just download them anywhere, and copy them somewhere your ubuntu instance has access to (let's say /home/me/oraclefiles)
Then run the following (as root, sudo -s or su):
mkdir /opt/oracle cd /opt/oracle unzip /home/me/oraclefiles/*.zip
You should end up with this directory structure:
/opt/oracle/instantclient_11_2 /opt/oracle/instantclient_11_2/sdk
Next, let's rename the instantclient_11_2 file to something more convenient:
mv instantclient_11_2 instantclient
next, enter the directory, and create non versioned symbolic links to the oci8 libraries we need:
ln –s libclntsh.so.11.1 libclntsh.so ln –s libocci.so.11.1 libocci.so
We should be all set, as long as you have pear installed on your server. If you don't, install it using the following command:
apt-get install php-pear
Then, install oci8 using pecl:
pecl install oci8
This will download the oci8 extension, and start compiling it. At some point, you will be asked for the path to your oracle libraries. When this happens, enter the following:
share,instantclient,/opt/oracle/instantclient
The install process should complete correctly, and the extension will be created.
The final step is to enable the oci8 extension in your PHP setup, for both CLI and module. This can easily be done by running the following:
echo "extension=oci8.so" >> /etc/php5/conf.d/oci8.ini
Restart your webserver, and PHP should have the oci8 extension. I hope this helps somebody :-)
Credits: this ubuntuforums.org post was quite useful to me: http://ubuntuforums.org/showthread.php?t=92528.
blog comments powered by Disqus