Oracle support in PHP?

John Korchok jkorchok at hotmail.com
Sun Dec 16 14:33:57 PST 2007


 

> -----Original Message-----
> From: Ryan Schmidt [mailto:ryandesign at macports.org] 
> Sent: Wednesday, December 12, 2007 6:00 PM
> To: John Korchok
> Cc: macports-users at lists.macosforge.org
> Subject: Re: Oracle support in PHP?
> 
> On Dec 12, 2007, at 08:50, John Korchok wrote:
> 
> >> On Dec 11, 2007, at 22:11, John Korchok wrote:
> >>
> >>>> On Dec 10, 2007, at 16:42, John Korchok wrote:
> >>>>
> >>>>> I had no errors or other problems installing the "oracle- 
> >>>>> instantclient" port or the "php5 +oracle" port. Thanks Ryan!
> >>>>
> >>>> Oh good!
> >>>>
> >>>>
> >>>>> I am assuming I still need to modify php.ini to point 
> at oci8.so, 
> >>>>> but I can't find it (oci8.o is there). I did find the libraries 
> >>>>> under lib/ oracle.
> >>>>
> >>>> Nope, nothing needs to be done in that regard. There is no
> >> oci8.so or
> >>>> any other separate file. The oci8 functions have simply
> >> been compiled
> >>>> into php and libphp5.so.
> >>>>
> >>>>
> >>>>> http://www.php.net/oci8 is just baffling. It reads like 
> a pile of 
> >>>>> potentially useful but untested information. Using the Instant 
> >>>>> Client (as they recommend) does not create an oracle user
> >> or group,
> >>>>> as far as I can tell.
> >>>>
> >>>> I didn't program any user or group creation into the oracle- 
> >>>> instantclient portfile, no. Should I have? What would that
> >> user/group
> >>>> be used for?
> >>>>
> >>>> The page is certainly Greek to me, since I haven't used Oracle.
> >>>
> >>> When I run phpinfo, the last configure command is:
> >>> '--with-oci8=instantclient,/opt/local/lib/oracle'
> >>>
> >>> At http://www.oracle.com/technology/pub/notes/
> >>> technote_php_instant.html,
> >>> under the heading "Enabling the PHP OCI8 Extension on 
> Linux " they 
> >>> suggest a syntax like:
> >>> '--with-oci8-instant-client=/opt/local/lib/oracle'
> >>
> >> As far as I can tell, the option was
> >> --with-oci8-instant-client=/path/ to/instantclient in earlier php 
> >> versions (maybe php 5.1.1 and earlier), and is 
> >> --with-oci8=instantclient,/path/to/instantclient now 
> (maybe since php 
> >> 5.1.2). This is mentioned in a note from wes9999 on
> >> http://www.php.net/oci8 and I say "maybe" for the versions because 
> >> the Oracle page you cite does say it has been updated for 
> php 5.1.2 
> >> so I don't know. But since they haven't managed to put out 
> an Intel 
> >> version in two years, and advocate using the problematic 
> >> DYLD_LIBRARY_PATH variable to get their libraries to work, I don't 
> >> trust Oracle very much.
> >>
> >>> Phpinfo has an oci8 section further, and it looks like it
> >> is getting
> >>> installed.
> >>
> >> I would expect so. So have you had any luck connecting with the 
> >> Oracle server or are you running into other problems?
> >
> > I'm not getting any connection yet. I saw the reference to the new 
> > path syntax, but may also be a path issue. Does MacPorts 
> set the path 
> > as root or as a user?
> 
> Set what path? If you mean DYLD_LIBRARY_PATH, I don't set it at all.  
> Instead, I used install_name_tool to fix the paths within the 
> oracle libraries so that DYLD_LIBRARY_PATH is no longer 
> necessary. You can see exactly what the port does with "port 
> cat oracle- instantclient" (or "port edit 
> oracle-instantclient") if you're interested.
> 
> What is the PHP code you use to attempt to establish a connection?  
> What error occurs as a result?

The Instant Client still requires an environment variable TNS_NAMES to point
to the sqlnet.ora and tnsnames.ora files. The files allow abbreviated
connection strings. For some reason, I was not able to set a TNS_NAMES that
the Instant Client would read (I tried setting it in the current user
'.profile', in 'opt/local/apache2/bin/envvars' to get the Apache user and
finally '/private/etc/profile' to make it system-wide. Nothing worked, the
Instant Client gives every appearance of not reading TNS_NAMES at all. I
finally gave up and set verbose connection strings:

$con = oci_connect('yourusername', 'yourpassword',
'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=serverurloripaddress)(PORT=portnu
mber))(CONNECT_DATA=(SID=servicename)(SERVER=DEDICATED)))'); 

It works! Macports PHP Oracle is a reality!




More information about the macports-users mailing list