Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old November 19th, 2005   #1
elmicha
First Cup of Ubuntu
 
Join Date: Dec 2004
Location: Bonn, Germany
Beans: 3
If you want to connect to an Oracle database with PHP, you can use Oracle's Instant Client and the oci8 module from pear.

Download the Basic and the SDK packages from http://www.oracle.com/technology/tec...antclient.html. At the time of this writing, the filenames are instantclient-basic-linux32-10.2.0.1-20050713.zip and instantclient-sdk-linux32-10.2.0.1-20050713.zip.

Unzip these files in a new directory, e.g. /opt/oracle/instantclient.

Code:
mkdir -p /opt/oracle/instantclient
cd /opt/oracle/instantclient
unzip instantclient-basic-linux32-10.2.0.1-20050713.zip
unzip instantclient-sdk-linux32-10.2.0.1-20050713.zip
echo /opt/oracle/instantclient >> /etc/ld.so.conf
ldconfig
The previous two lines are supposed to create symlinks named libclntsh.so and libocci.so which we will need later. In my case these symlinks were not created by ldconfig, so I created them manually.

Code:
ln -s libclntsh.so.10.1 libclntsh.so
ln -s libocci.so.10.1 libocci.so
In the next step we will download the oci8 module with pear. Pear is in the php-pear package.

Code:
apt-get install php-pear
"Normally" we should be able to just use pear install oci8 now, but apparently pear is not able to figure out where the instantclient libraries are. So we will just download the oci8 module and build it on our own.

Code:
mkdir -p /usr/local/src
cd /usr/local/src
pear download oci8
tar xzf oci8-1.1.1.tgz
cd oci8-1.1.1
phpize
./configure --with-oci8=shared,instantclient,/opt/oracle/instantclient
make
make install
The oci8-1.1.1.tgz filename will of course change for newer releases.
To enable the oci8 module in the php.ini (/etc/php5/apache2/php.ini and /etc/php5/cli/php.ini), add a line
Code:
extension=oci8.so
(put this line after the examples starting with ;extension).

Now stop and start Apache. You should see the oci8 module in the output of phpinfo().
elmicha is offline   Reply With Quote
Old March 24th, 2006   #2
mthaddon
A Carafe of Ubuntu
 
mthaddon's Avatar
 
Join Date: Mar 2005
Location: San Francisco, US
Beans: 141
Hardy Heron (Ubuntu Development)
Re: Howto: Install Oracle Instant Client and PHP OCI8 module

I've followed the instructions, but get the following error when running the ./configure command. Do I need version 3.4 or something (I've seen as a problem elsewhere)?

checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check


Thanks, Tom
__________________
Dell Inspiron 1420n running Hardy i386.
mthaddon is offline   Reply With Quote
Old March 27th, 2006   #3
mthaddon
A Carafe of Ubuntu
 
mthaddon's Avatar
 
Join Date: Mar 2005
Location: San Francisco, US
Beans: 141
Hardy Heron (Ubuntu Development)
Re: Howto: Install Oracle Instant Client and PHP OCI8 module

Solved with:

sudo apt-get install build-essential

Thanks, Tom
__________________
Dell Inspiron 1420n running Hardy i386.
mthaddon is offline   Reply With Quote
Old April 7th, 2006   #4
bjverde
First Cup of Ubuntu
 
Join Date: Apr 2006
Beans: 1
Re: Howto: Install Oracle Instant Client and PHP OCI8 module

for phpize use:


sudo apt-get install php5-dev
bjverde is offline   Reply With Quote
Old July 19th, 2006   #5
masonite
First Cup of Ubuntu
 
Join Date: Jul 2006
Beans: 1
Re: Howto: Install Oracle Instant Client and PHP OCI8 module

An excellent howto! Thanks - you've really saved me!

I tried with the basiclite version that oracle makes available and it didn't work very well (at all) - the issue was that it's missing the libociei.so library.

Be sure to use the full basic client. Currently instantclient-basic-linux32-10.2.0.2-20060331.zip

I also had to set the environ a little as well:
export LD_LIBRARY_PATH=/opt/oracle/instantclient/

Good luck!
masonite is offline   Reply With Quote
Old July 20th, 2006   #6
asg123
First Cup of Ubuntu
 
Join Date: Jul 2006
Location: Vladivostok, Russia
Beans: 1
Re: Howto: Install Oracle Instant Client and PHP OCI8 module

At least with Ubuntu 6.06 and oci8-1.2.1 you don't need to compile oci8 extension manually. Just run:
Code:
pecl install oci8
and enter "instantclient,/opt/oracle/instantclient" when it'll prompt for the path to ORACLE_HOME dir
asg123 is offline   Reply With Quote
Old July 24th, 2006   #7
ehudokai
First Cup of Ubuntu
 
Join Date: Dec 2005
Beans: 3
Re: Howto: Install Oracle Instant Client and PHP OCI8 module

Is the module supposed to show up in phpinfo after its installed?
ehudokai is offline   Reply With Quote
Old August 13th, 2006   #8
belgampaul
First Cup of Ubuntu
 
Join Date: Oct 2005
Beans: 3
Re: Howto: Install Oracle Instant Client and PHP OCI8 module

Quote:
Originally Posted by masonite View Post
An excellent howto! Thanks - you've really saved me!

I tried with the basiclite version that oracle makes available and it didn't work very well (at all) - the issue was that it's missing the libociei.so library.

Be sure to use the full basic client. Currently instantclient-basic-linux32-10.2.0.2-20060331.zip

I also had to set the environ a little as well:
export LD_LIBRARY_PATH=/opt/oracle/instantclient/

Good luck!
i had to set up the LD_LIBRARY_PATH with a :

SetEnv LD_LIBRARY_PATH /opt/oracle/instantclient

in apache.

export LD_LIBRARY_PATH=/opt/oracle/instantclient/ may still work but then you gotta be more precise for what user you do this.

more about this at http://www.phpfreaks.com/forums/inde...5498.msg382340
belgampaul is offline   Reply With Quote
Old September 14th, 2006   #9
underpope
Spilled the Beans
 
Join Date: Jun 2005
Beans: 13
Send a message via AIM to underpope Send a message via Yahoo to underpope
Re: Howto: Install Oracle Instant Client and PHP OCI8 module

I tried doing that, but Apache is disconnecting and throwing a segmentation fault. How can I fix that?
underpope is offline   Reply With Quote
Old October 10th, 2007   #10
msalahat
First Cup of Ubuntu
 
Join Date: Oct 2007
Beans: 2
Re: Howto: Install Oracle Instant Client and PHP OCI8 module

Hi ,
enter I didl this command "pecl install oci8"
I got this error ?
/usr/bin/ld: skipping incompatible /opt/oracle/instantclient//libclntsh.so when searching for -lclntsh
/usr/bin/ld: cannot find -lclntsh
collect2: ld returned 1 exit status
make: *** [oci8.la] Error 1
ERROR: `make' failed

Could you help me ?
msalahat is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:00 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry