Thread: OS X Oracle Instant Client instructions with PHP 4


Permlink Replies: 6 - Pages: 1 - Last Post: Mar 10, 2007 6:30 AM Last Post By: jpiwowar
user448198

Posts: 1
Registered: 08/24/05
OS X Oracle Instant Client instructions with PHP 4
Posted: Aug 24, 2005 10:05 AM
Click to report abuse...   Click to reply to this thread Reply
I tried using the directions here:
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/macsoft.html

and they did not work at all with PHP. None of the oci_ PHP functions worked. I wrote some new directions which seem to work. They've been tested with several clean installs of OS X and have shown no problems.


Installing PHP with Oracle Instant Client on Mac OS X
This will allow you to use the oci* PHP functions.
James Cho, jamec@umich.edu

Prerequisites

* OS X Xcode Tools (or any working GCC compiler)
* Personal Web Sharing (or any Apache 1.3.x server) and PHP (4.3.x) should be enabled (other versions may require a little modification)
* Basic Terminal Skills

Instructions

NOTE: Replace every "instantclient" mentioned below with the actual name of YOUR instant client folder (such as instantclient_10).

1. Download and unzip the Oracle Instant Client Basic and SDK packages:

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/macsoft.html
(Disregard the installation instructions at that page.)

You may have to register on Oracle's website. You may also google "oracle mac os x instant client" if the above link is dead.

2. Move the sdk folder from the SDK zip file into the instantclient folder, and move the instantclient folder into /usr/lib using Terminal.

3. Add the following line to the beginning of the /usr/sbin/apachectl file. Remember to replace "instantclient" with the actual folder name. Leave off the trailing slash after "instantclient." This will properly set the LD_LIBRARY_PATH environment variable upon apache startup.

export LD_LIBRARY_PATH=/usr/lib/instantclient

4. Create the directory structure /b/729/rdbms/lib and copy the file libclntsh.dylib.10.1 from the instantclient folder to the /b/729/rdbms/lib directory.

5. Create a symbolic link as /usr/lib/instantclient/libclntsh.dylib directing to libclntsh.dylib.10.1.

6. Download the PHP source code:

http://us2.php.net/downloads.php

7. Unzip the source file if necessary, then navigate to the PHP directory in Terminal. Configure, build and install PHP as shown. (Remember to replace "instantclient" below with the actual folder name.):

$ tar xvjf php-4.3.x.tar.bz2
$ cd php-4.3.x
$ sudo bash
# ./configure --with-apxs=/usr/sbin/apxs --with-oci8-instant-client=/usr/lib/instantclient
# make
# make install

If "make" returns errors, ensure that the LD_LIBRARY_PATH is set with no trailing slash, and that your "configure" command was correct.

PHP with the Oracle Client Libraries should now be installed. Stop and start apache (apachectl restart will not suffice) if necessary.

Message was edited by:
user448198

Message was edited by:
user448198

Message was edited by:
user448198

user551513

Posts: 1
Registered: 01/04/07
Re: OS X Oracle Instant Client instructions with PHP 4
Posted: Jan 4, 2007 8:16 AM   in response to: user448198 in response to: user448198
Click to report abuse...   Click to reply to this thread Reply
For php5 the ./configure command syntax has been changed

It is now: --with-oci8=instantclient,<path-to-instant-client>

./configure --with-apxs=/usr/sbin/apxs --with-oci8=instantclient,/usr/lib/instantclient
user553087

Posts: 1
Registered: 01/13/07
Re: OS X Oracle Instant Client instructions with PHP 4
Posted: Jan 13, 2007 5:08 PM   in response to: user551513 in response to: user551513
Click to report abuse...   Click to reply to this thread Reply
Hi,

I just downloaded Instant Client, and tried to run it on my macbook pro.
I got an error when I tried to start the sql*plus.
It asked a username and password which I certainly dont know. How to set up the username and password for the first time?

The following is the error message I got:

sh-2.05b# ./sqlplus

SQL*Plus: Release 10.1.0.3.0 - Production on Sun Jan 14 02:07:19 2007

Copyright (c) 1982, 2004, Oracle. All rights reserved.

Enter user-name:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Paul Preston

Posts: 100
Registered: 01/31/03
Re: OS X Oracle Instant Client instructions with PHP 4
Posted: Jan 15, 2007 7:50 AM   in response to: user553087 in response to: user553087
Click to report abuse...   Click to reply to this thread Reply
Sounds like you expected Instant client to give you a little database instance?

Sorry if I got that wronf and you already know all this but:

Instant client simply lets you connect to a database that already exists.

This would usually be at some IP address on a network you are connected to either by ethernet or wirelessly.

If you are connectling to an Oracle database then you need to know the Oracle username and password and the details of where the database is. These details are usually entered in a file called tnsnames.ora which is in the directory pointed to by the unix symbol TNS_ADMIN which should be setup in your .profile or .bashrc file.

At the terminal prompt:
l001625:~ skiv$ echo $TNS_ADMIN
/Volumes/Dot/Applications/InstantClient/instantclient10_1/
and:
l001625:~ skiv$ ls -l $TNS_ADMIN/tnsnames.ora
-rw-rw-r-- 1 skiv skiv 1821 Nov 14 10:36 /Volumes/Dot/Applications/InstantClient/instantclient10_1//tnsnames.ora

If you have not conneted before then tnsnames.ora will contain a specimen example that you can edit with your own database details.

The you can type sqlplus user@instance and then type the password and it all works.

Paul
user563158

Posts: 1
Registered: 03/09/07
Re: OS X Oracle Instant Client instructions with PHP 4
Posted: Mar 9, 2007 12:28 AM   in response to: user448198 in response to: user448198
Click to report abuse...   Click to reply to this thread Reply
Hi...

I have follow exactly what is written here.. Thanks so much.. The PHP eventually can understand the oci functions, but there was an error when i'm calling OCILogon from my php:

Warning: ocilogon() [function.ocilogon]: _oci_open_session: OCIHandleAlloc OCI_HTYPE_SVCCTX: OCI_INVALID_HANDLE in /Library/WebServer/Documents/projects/project8/index.php on line 21

My code in php was simply:
<?
$c = OCILogon('username', 'password', '//host:port/SID');
?>

As i googled for answer, i find that it might because I haven't setup my ORACLE_HOME or TNS_ADMIN. However, i really have no idea of how to setup them.. (I'm a novice MAC user and very horrible with Terminal) I wonder if there are any next step after the installation? Thanks alot in advance!

FYI, I'm using MAC OS X Server Version 10.4.9. I'm trying to connect to an oracle database at other server side without having oracle at myside.

Thanks alot in advance!

Erlin.D

Message was edited by:
user563158
user563301

Posts: 1
Registered: 03/09/07
Re: OS X Oracle Instant Client instructions with PHP 4
Posted: Mar 9, 2007 9:36 PM   in response to: user551513 in response to: user551513
Click to report abuse...   Click to reply to this thread Reply
I don't understand the proper syntax for this remark: Create a symbolic link as /usr/lib/instantclient/libclntsh.dylib directing to libclntsh.dylib.10

What exactly do you type in the terminal? I tried the following but it doesn't seem right as the ./compile command returned an error stating it didn't understand the link:

ln -s /usr/lib/instantclient10_1/libclntsh.dylib libclntsh.dylib.10.1

FYI: the name of my folder is instantclient10_1

Anyone have a clue for me?

Thanks
jpiwowar

Posts: 485
Registered: 09/07/98
Re: OS X Oracle Instant Client instructions with PHP 4
Posted: Mar 10, 2007 6:30 AM   in response to: user563301 in response to: user563301
Click to report abuse...   Click to reply to this thread Reply
Try the other way around:

ln -s /usr/lib/instantclient/libclntsh.dylib.10 libclntsh.dylib

It sounds like the instructions are to create a symbolic link called libclntsh.dylib, pointing to libclntsh.dylib.10. The command you supplied creates a symbolic link called libclntsh.dylib.10.1, pointing to /usr/lib/instantclient10_1/libclntsh.dylib. The syntax for ln is ln <target file to which you are linking> <name of link>
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums