Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Issues with DBD::Oracle and an apache environment

by l2kashe (Deacon)
on Jun 17, 2005 at 14:59 UTC ( #467753=perlquestion: print w/ replies, xml ) Need Help??
l2kashe has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks

I have a suite of utilities which work in a shell environment but fail when running as a cgi

To add a bit more detail I am using DBD::Oracle v1.16, on a RH enterprise host running apache, writing cgis via CGI::Safe, connecting to a Solaris 8 host running Oracle 9.x (not sure here, and I am not sure it matters)

The code runs just dandy from the command line, but when executing as a CGI I get the following error

"DBI connect('apdtest','pwh',...) failed: ERROR OCIEnvNlsCreate (check ORACLE_HOME and NLS settings etc.) at blah blah blah"

No problem, lets set ORACLE_HOME and LD_LIBRARY_PATH.. No dice
Ok, lets read the POD.. Ok these NLS_LANG and NLS_NCHAR variables might need to be set as well... Nope that didn't work
Hrm... There is this ORACLE_SID, which I think is my creds.. tweak tweak tweak.. still no dice, not sure where to read up on this

Off to see the monks and supersearch it.
Bingo I hit on Oracle DBD problems with mod_perl and Oracle database connection (sorry haven't been here in awhile and forgot how to link direct), but I have already covered those routes. Additionally I have attempted setting these variables in a BEGIN block as well as main.

I am getting a touch deperate at this point and look forward to some guidance on what my issues may be

Update: Problem solved. It was a permission issue on the root directory oracle was installed to. The executing user didn't have sufficient permission to access the ORACLE files.

use perl;
Everyone should spend some time pounding nails with their forehead for a while before they graduate to complicated stuff like hammers. - Dominus

Updated Steve_p - converted node numbers to links

Comment on Issues with DBD::Oracle and an apache environment
Replies are listed 'Best First'.
Re: Issues with DBD::Oracle and an apache environment
by JupiterCrash (Monk) on Jun 17, 2005 at 15:37 UTC
    Compare the environment when ran from the web to the environment when ran from the command line. Have your perl script print out the entire environment and look for differences.

    You might find something like TNS_ADMIN is set in one, but not the other.

    It sounds like you are already setting LD_LIBRARY_PATH, ORACLE_HOME, and ORACLE_SIDE -- but also make sure that your library files in the LD_LIBRARY_PATH have adequate permissions for the user who runs your Apache to access them.


      It is amazing how humbling system administration can be.

      Matt, Thank You.
      I forgot under Linux the default permissions on home directories is 600 and long story short oracle is installed in a users dir.

      Problem solved

      use perl;
      Everyone should spend some time pounding nails with their forehead for a while before they graduate to complicated stuff like hammers. - Dominus

Re: Issues with DBD::Oracle and an apache environment
by Rhose (Priest) on Jun 17, 2005 at 15:14 UTC
    If you are using the Oracle instant client, make sure LD_LIBRARY_PATH is set, otherwise, make sure ORACLE_HOME is set.

    If the database is on the same box and you are not connecting through a listener, make sure ORACLE_SID is set (not the case for you). If you are connecting using an Oracle listener (which is your case as the database is on another box), make sure TNS_ADMIN is set.

    TNS_ADMIN should point to your connectivity file(s) -- tnsnames.ora (tnsnav.ora, sqlnet.ora, protocol.ora)

Re: Issues with DBD::Oracle and an apache environment
by JediWizard (Deacon) on Jun 17, 2005 at 15:55 UTC

    JupiterCrash makes a point (++). However I feel the need to explain why this may be an issue:

    What sort of web server are you using?

    Assuming you use Apache, the environment varialbes available to your script are limitted for security reasons. This would explain why a script runs from the shell, but fails as a CGI. Again, assuming you use apache, look at the "SetEnv" and "PassEnv" config parameters. If this is the problem, a simple modification of your httpd.conf file, and a bounce of apache will solve all your wows.

    If you are not using apache, investigate the configuration of your webserver.

    Update Apparently your problem is solved by a previous response, but it is still good to understand the difference between the ENV varialbe avaiable from the shell, versus those passed to a CGI from your web server.

    They say that time changes things, but you actually have to change them yourself.

    —Andy Warhol

      Thank you. ++

      Super search plus your post was just what I needed to get DBD::Oracle/Apache working.

      me go back to work now...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://467753]
Approved by davidrw
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2016-05-06 07:43 GMT
Find Nodes?
    Voting Booth?