Install help for connecting to oracle database

#1
Hi: I want to use php with lightspeed server to connect to an oracle database. Any pointers on what additional steps I need to do after installing lightspeed?

Thanks in advance
Ray
 

xing

LiteSpeed Staff
#4
Ray, yes that's that the right wiki article. Just follow the addition steps/config lines required for oracle driver via www.php.net instructions. Our wiki tells you how to compile optimized PHP for LiteSpeed. You need to visit php.net to find out how to compile oracle driver for PHP.
 
#5
Ray, yes that's that the right wiki article. Just follow the addition steps/config lines required for oracle driver via www.php.net instructions. Our wiki tells you how to compile optimized PHP for LiteSpeed. You need to visit php.net to find out how to compile oracle driver for PHP.
One more question. Do I need to have oracle client installed on the machine where I am installing the LiteSpeed and PHP?

Thanks
Ravi
 
#7
Yes, I think you probably need to install oracle client, at least make OCI client library and header file available.
Hi:
Sorry I am new to PHP and am trying to understand what I have to do and why. In the perl world, I would install perl and add the DBI and DBD:Oracle modules to be able to connect to a oracle database. But in the PHP world you are saying the PHP does not come with modules/libraries necessary to connect to a oracle database. Rather, I have to compile PHP with oracle support. Am I correct?

So in Step 5 (wiki), I will run something like the following
./configure '--prefix=/php5' '--with-litespeed' '--with-config-file-path=../conf' --with-oracle=$ORACLEHOME --with-oci8=$ORACLEHOME

The oracle PHP FAQ also says the following
Ensure that your "extension_dir" parameter (in php.ini) points to the location where the above extension files reside.

What exactly do I have to add in ~lsws/conf/php.ini?

Thanks for your help.
Ravi
 

mistwang

LiteSpeed Staff
#8
The Oracle PHP extension modules were compiled into the PHP binary with option "--with-oracle=... --with-oci8=...", you don't need to do anything about "extension_dir", that's for the pre-compiled Oracle modules.

Your PHP binary should work well with Oracle now.
 
#9
The Oracle PHP extension modules were compiled into the PHP binary with option "--with-oracle=... --with-oci8=...", you don't need to do anything about "extension_dir", that's for the pre-compiled Oracle modules.

Your PHP binary should work well with Oracle now.

Hi: after compiling and completing all the steps, When I try to access a php page with oracle functions, I get a page saying

504 Service Unavailable


I notice the following error in /lswsinstall/logs/stderr.log
ld.so.1: lsphp: fatal: libnnz10.so: open failed: No such file or directory


I have this file in the LD_LIBRAY_PATH. Why is litespeed not able to find it

bash-2.05$ echo $LD_LIBRARY_PATH
/export/home/rawlog/oracle/instantclient_10_2:/usr/local/lib:/oracle/g01/software/rdbms/9.2.0.6/lib:/usr/lib
bash-2.05$ ls -l /export/home/rawlog/oracle/instantclient_10_2/libnnz10.so
-rwxr-xr-x 1 rawlog staff 6135928 Feb 6 15:22 /export/home/rawlog/oracle/instantclient_10_2/libnnz10.so


Thanks
Ravi
 

mistwang

LiteSpeed Staff
#12
You need to change "lsphp" configuration under "external app" tab from the web admin interface.
just add "LD_LIBRARY_PATH=...." to "environment" configuration entry, this environment varible must be set explicitly from there.
 
#13
You need to change "lsphp" configuration under "external app" tab from the web admin interface.
just add "LD_LIBRARY_PATH=...." to "environment" configuration entry, this environment varible must be set explicitly from there.
Now I get the following error in stderr.log when I try to run a simple oracle connect. Looks like it still has some problems with LD_LIBRARY_PATH

2007-02-07 13:17:43.536 [NOTICE] [199.11.4.59:6443-0#Example] [STDERR] PHP Warning: ocilogon() [<a href='function.ocilogon'>function.ocilogon</a>]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that LD_LIBRARY_PATH includes the directory with Oracle Instant Client libraries in /export/home/rawlog/lsws/DEFAULT/html/ravioraconnect.php on line 3
2007-02-07 13:17:43.537 [NOTICE] [199.11.4.59:6443-0#Example] [STDERR] PHP Warning: ociparse() expects parameter 1 to be resource, boolean given in /export/home/rawlog/lsws/DEFAULT/html/ravioraconnect.php on line 7
2007-02-07 13:17:43.537 [NOTICE] [199.11.4.59:6443-0#Example] [STDERR] PHP Warning: ociexecute() expects parameter 1 to be resource, null given in /export/home/rawlog/lsws/DEFAULT/html/ravioraconnect.php on line 8
2007-02-07 13:17:43.537 [NOTICE] [199.11.4.59:6443-0#Example] [STDERR] PHP Warning: ocifetchinto() expects parameter 1 to be resource, null given in /export/home/rawlog/lsws/DEFAULT/html/ravioraconnect.php on line 9
2007-02-07 13:17:43.537 [NOTICE] [199.11.4.59:6443-0#Example] [STDERR] PHP Warning: ocilogoff() expects parameter 1 to be resource, boolean given in /export/home/rawlog/lsws/DEFAULT/html/ravioraconnect.php on line 16

Any ideas?
Thanks
RM

The following

<?php

$conn = OCILogon('usera', 'sql', '//oracletest:1521/Vitalnet');

$query = 'select table_name from user_tables';

$stid = OCIParse($conn, $query);
OCIExecute($stid, OCI_DEFAULT);
while ($succ = OCIFetchInto($stid, $row)) {
foreach ($row as $item) {
echo $item." ";
}
echo "<br>\n";
}

OCILogoff($conn);

?>
 
#14
finally got it to work!!! I had to use the following two lines in the php script.
PutEnv("LD_LIBRARY_PATH=/export/home/rawlog/oracle/instantclient_10_2");
PutEnv("ORACLE_HOME=/oracle/g01/software/rdbms/9.2.0.6");

Any ideas why the lsphp doesn't use these environment variables?

I will send post another message with what all I did to get this working.

Thanks
Ravi
 

mistwang

LiteSpeed Staff
#15
I think you need to add "ORACLE_HOME" env to "Environment" configuration of lsphp as well. No need to use PutEnv().

LSWS has strict security policy, when LSWS start a external application, it will not set any environment variables in your current system environment, you have set them explicitly in the configuration.
 
Top