Install help for connecting to oracle database

Discussion in 'PHP' started by reshu1596, Feb 4, 2007.

  1. reshu1596

    reshu1596 Member

    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
  2. mistwang

    mistwang LiteSpeed Staff

    Just follow the steps on our wiki to compile your own PHP binary with oracle module included.
  3. reshu1596

    reshu1596 Member

  4. xing

    xing LiteSpeed Staff

    Ray, yes that's that the right wiki article. Just follow the addition steps/config lines required for oracle driver via instructions. Our wiki tells you how to compile optimized PHP for LiteSpeed. You need to visit to find out how to compile oracle driver for PHP.
  5. reshu1596

    reshu1596 Member

    One more question. Do I need to have oracle client installed on the machine where I am installing the LiteSpeed and PHP?

  6. mistwang

    mistwang LiteSpeed Staff

    Yes, I think you probably need to install oracle client, at least make OCI client library and header file available.
  7. reshu1596

    reshu1596 Member

    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.
  8. mistwang

    mistwang LiteSpeed Staff

    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. reshu1596

    reshu1596 Member

    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 lsphp: fatal: 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
    bash-2.05$ ls -l /export/home/rawlog/oracle/instantclient_10_2/
    -rwxr-xr-x 1 rawlog staff 6135928 Feb 6 15:22 /export/home/rawlog/oracle/instantclient_10_2/

  10. mistwang

    mistwang LiteSpeed Staff

    Try adding LD_LIBRARY_PATH to the "environment" section of the lsphp external application.
  11. reshu1596

    reshu1596 Member

    I am sorry, not sure I understand what that means. Is this a particular file or something I need to add before compiling?

  12. mistwang

    mistwang LiteSpeed Staff

    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. reshu1596

    reshu1596 Member

    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] [] [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] [] [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] [] [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] [] [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] [] [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?

    The following


    $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";


  14. reshu1596

    reshu1596 Member

    finally got it to work!!! I had to use the following two lines in the php script.

    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.

  15. mistwang

    mistwang LiteSpeed Staff

    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.

Share This Page