Page 1 of 1

Compiling PHP with Oracle support

Posted: Mon Apr 18, 2005 8:16 am
by MattSharp
So I have spent countless hours in the last week trying to successfully compile PHP with Oracle support. I know that I have a working Oracle database because I have accessed it and written a Java application that uses it.

I am running Fedora Core 3 and the regular PHP install for FC3 does not come with Oracle support. I have read lots of things lots of places but I think what I want to use is the OCI functions for PHP. I downloaded the SRPM for PHP and in the SPEC file I added two lines for Oracle support.

Code: Select all

--with-oci=/home/user/product/10.1.0/Db_1
--with-oracle=/home/user/product/10.1.0/Db_1
If I do this and run the rpmbuild command, it will fail telling me I am missing need libraries. After hours of tinkering I have discovered that if I remove the --with-oracle line, but leave the oci one, it will compile. Then I can start Apache just fine, but I am presented with an error about the oci functions being unknown. I am assuming because I also need that --with-oracle line. My first question is, is that true?

My second question is, if I do need that --with-oracle line, what should the directory be, and why isn't it the same one as --with-oci.

Do I need anything else installed other than the Oracle database to work? I have seen this Oracle Client thrown around a lot but I was under the impression that isn't needed if you are using the whole Oracle database on the same server.

I really need to get this working. I would appreciate any help anyone can give.

Posted: Tue Jun 14, 2005 2:40 pm
by jayloo
I will share my installation on my FC3 server.

You do not need the entire oracle database installed if it is not needed. My webserver using php are not the same servers running oracle. You need the oracle client libraries for php to compile with no oracle related errors. The client only install is small and simple to do. You will save a lot of disk space.

Im using this example on servers running php 4.1.2/apache 1.3.31 and php 5.0.4/apache 1.3.33.

I installed an oracle 8i client on the same server that is running php/apache. All of my databases are 9i though. As I understand it you can not compile php using the client libraries from a 9i or 10g client.

Here is my configure line....

Code: Select all

'./configure' '--with-mysql' '--with-oci8=/u01/app/oracle/product/8.1.7' '--with-apxs=/www/bin/apxs'
Here is how I connect to my databases...

Code: Select all

$db = &quote; (DESCRIPTION = 	(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521)) (CONNECT_DATA = (SID = ASID)))&quote;; 
$conn = ocilogon(&quote;username&quote;,&quote;password&quote;,$db);
Then to query the db I use something like....

Code: Select all

$stmt = ociparse($conn,&quote;SELECT SOMETHING from somewhere&quote;);
	ociexecute($stmt);
  while (OCIFetch($stmt)) {
    $result_something = ociresult($stmt,&quote;SOMETHING _ID&quote;);
    echo $result_something;
  }
Hope this helps.