Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 09-04-2003, 09:32 AM   #1
LQ Newbie
Registered: Aug 2003
Distribution: gentoo, redhat
Posts: 12

Rep: Reputation: 0
Compiling php with oracle support

Hi I'm looking for some help with compiling php with oracle support on RH7.1/RH9.

I've looked at php's site and it says I need to set up some environment variables like ORACLE_HOME & LD_PRELOAD.

I know what ORACLE_HOME is but I haven't got a clue about the rest of them. Any ideas? Thanks


Here is my own answer

Configuring apache & php with OCI8 support

For oracle support in php all you need is the oci libraries installed from the client.
Set these variables before you install the client. With this basic install of the oracle client you need to create a tnsnames.ora file and sqlnet.ora file under /path/to/your/installdir/network/admin.

export ORACLE_HOME=/path/to/your/installdir
export ORACLE_BASE=/base/dir
export ORACLE_OWNER=user
export ORACLE_SID=database
export ORACLE_TERM=xterm
export TNS_ADMIN=/path/to/your/installdir/network/admin

# Set the kernel to use the old Linuxthreads

export LD_ASSUME_KERNEL=2.4.1
export THREADS_FLAG=native



export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data

# Edit Paths




# export CLASSPATH # You don't need to set the CLASSPATH variable.

export PATH=$PATH #:$ORACLE_HOME/bin

Go through the normal procedure of the oracle client install but select custom install. From there select oci libraries then finish the install. From there compile apache then php with the following.

Configuring, compiling apache & php

./configure --prefix=/path/to/your/installdir --enable-so --enable-anything-else-you-want
make ; make install

./configure --with-oci8=/path/to/your/installdir –with-apxs2=/path/to/your/installdir/bin/apxs –enable-sigchild --enable-anything-else-you-want
make ; make install

When configuring php sometimes $ORACLE_HOME will work but it's better to enter the full path instead of $ORACLE_HOME.

Finishing up

After some testing I found you only need ORACLE_HOME set in apaches envvars.

export ORACLE_HOME=/path/to/your/installdir

Edit the httpd.conf file as you normally would.

Sometimes it's necessary to add the webserver user to the db group but I found you can get by without this. What you do need is a tnsnames.ora file and a sqlnet.ora file setup to point to your db server. If you have either file missing you will get this error:

Warning: ocilogon(): _oci_open_server: Error while trying to retrieve text for error ORA-12154

After much head banging I figured this out. If you google this error you get a lot of people saying its to do with your environment. In my case it was sqlnet.ora file not being created. If you still receive this error try setting the other oracle env in apache. You don't need to use putenv in php or SetEnv in apache, also you don't need to put the contents of tnsnames.ora file in a php variable.

On the two, three webservers that I've done this install these settings have worked fine. I've tested this install with rh9, httpd-2.0.48, httpd-2.0.50, php-4.3.4, php-4.3.8. When I get time I'll try it on Suse.


Getting oracle to work with php can be a pain in the ass but once you do it works like a charm. Thanks


Note: If you want to use php with oracle on the comand line make sure all the environment variavles for oracle are set.

Last edited by fintan; 09-08-2004 at 10:14 AM.
Old 12-31-2006, 12:34 PM   #2
Registered: Oct 2006
Location: JNB, SA
Posts: 33

Rep: Reputation: 15
I have installed PHP,Apache,OCI8 on my two production servers recently , and i agree with you that some time php , oracle connectivity is pain in ass , here is my server detail and recommended packages version,

platform: IBM x system , x86_64, RHEL 4 Updated 4
Oracle Version: Oracle 10g release 2
Apache: apache_1.3.37
PHP: php-4.3.11

Here are few docs, I took help from:


Last edited by nayyares; 12-31-2006 at 12:36 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling in ACPI support on Compaq 2135CA (system crashes while compiling) Dag Linux - Laptop and Netbook 20 07-30-2004 07:56 PM
Problems compiling php with imap, ssl... support tveiga Linux - Software 1 01-16-2004 09:06 PM
Oracle 9i R2 and MySQL 4.0.X support ravishankar Linux - Newbie 2 10-03-2003 09:47 PM
Oracle does not support chkconfig puzz_1 Linux - Software 1 07-31-2003 01:18 PM
Trouble compiling JPEG support with PHP MusicmanAN Programming 0 05-13-2001 05:08 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration