You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Geoffrey Young <ge...@modperlcookbook.org> on 2005/09/01 00:19:10 UTC

Re: Apache::Test not finding global config file


William McKee wrote:
> On Wed, Aug 31, 2005 at 11:54:57AM -0400, Geoffrey Young wrote:
> 
>>$self->{httpd_basedir}, which looks to be calculated based on the location
>>of the httpd binary.  but it looks like it ought to be using HTTPD_ROOT
>>instead.  at least if it's defined.
>>
>>try this (completely untested)
> 
> 
> Perfect! That worked just fine. How can we get it added to A::T?

if you can do me the favor of trying a few different configuration scenarios
(including 1.3, non-apxs, /usr/local/apache, etc) and making sure nothing
breaks, that would be great.  the box where my matrix used to live had a
hard drive failure, so I'm slowly rebuilding it as I find the time.

if those all look good I'll commit it.

> PS: Sorry I missed you at YAPC this year. Perrin will tell you that I
> tried my best to track you down. Next time...

next time just nail me down after one of my talks :)

--Geoff

Re: Apache::Test not finding global config file

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> I removed your original patch and added this one then tested it under
> the two systems above. Looks good.

committed.

--Geoff

Re: Apache::Test not finding global config file

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> I removed your original patch and added this one then tested it under
> the two systems above. Looks good.

committed.

--Geoff

Re: MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate (check ORACLE_HOME and NLS settings)

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Thomas Hilbig wrote:
> Hi,
> 
> I am struggling with a (simple?) DBI problem under MP2
> on Fedora Core 3.  A script that uses Oracle-DBI works
> under regular CGI but fails under MP2 with the
> following error:
>  httpd: 2.0.54
>  MP2: 2.0.1
>  Fedora Core 3: 2.6.12-1.1376_FC3 
>  Oracle: 10g Release 2 (10.2.0)
>  DBI - 1.48
>  DBD::Oracle 1.16
How about the script and related config or a scaled down script?

-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com


Re: MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate (check ORACLE_HOME and NLS settings)

Posted by Thomas Hilbig <th...@yahoo.com>.

--- "Philip M. Gollucci" <pg...@p6m7g8.com> wrote:

> Thomas Hilbig wrote:
> >
>
$ENV{ORACLE_HOME}='/home/oracle/product/10.2.0/db_1';
> >   $ENV{'ORACLE_SID'}="tomdb1";
> >  
> >
>
$ENV{'LD_LIBRARY_PATH'}="/home/oracle/product/10.2.0/db_1/lib";
> >   $ENV{'LD_ASSUME_KERNEL'} = "2.4.1" ;
> >   $ENV{'LD_PRELOAD'} =
> > "/usr/lib/libInternalSymbols.so" ;
> >   $ENV{'NLS_LANG'}=  "AMERICAN_AMERICA.UTF8" ;
> >   $ENV{'TNS_ADMIN'}=  "/home/oracle" ;
> Have you tried adding these to the startup files of
> the httpd and/or oracle user?
> 

No I haven't.  Other than the snippet above, the
httpd.conf file I am using to trouble-shoot is
straight out of the 2.0.54 installation.

> You don't have any Apache::DBI or connect_on_init()
> happening right ?

I did install Apache::DBI from cpan, but I am not
explicitly using it.

Tom

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate (check ORACLE_HOME and NLS settings)

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Thomas Hilbig wrote:
> $ENV{ORACLE_HOME}='/home/oracle/product/10.2.0/db_1';
>   $ENV{'ORACLE_SID'}="tomdb1";
>  
> $ENV{'LD_LIBRARY_PATH'}="/home/oracle/product/10.2.0/db_1/lib";
>   $ENV{'LD_ASSUME_KERNEL'} = "2.4.1" ;
>   $ENV{'LD_PRELOAD'} =
> "/usr/lib/libInternalSymbols.so" ;
>   $ENV{'NLS_LANG'}=  "AMERICAN_AMERICA.UTF8" ;
>   $ENV{'TNS_ADMIN'}=  "/home/oracle" ;
Have you tried adding these to the startup files of the httpd and/or oracle user?

You don't have any Apache::DBI or connect_on_init() happening right ?



-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com

Re: MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate (check ORACLE_HOME and NLS settings)

Posted by Thomas Hilbig <th...@yahoo.com>.
--- Perrin Harkins <pe...@elem.com> wrote:
> 
> See PerlPassEnv:
>http://perl.apache.org/docs/1.0/guide/config.html#PerlSetEnv_and_PerlPassEnv

This didn't help, as expected since I already had the
PerlSetEnv in my httpd.conf file.  PerlSetEnv sets and
passes the environment variables; but I did try
different combinations of PerlSetEnv and PerlPassEnv
just in case.  Somewhere along the way, ALL of my
environment variables (except LANG, TERM, PATH) are
being wiped away (judging from the dump of the
dbitrace.log file) under mod perl.  All ENV varibles
do show up in the script (CGI and MP), but only in the
dbitrace.log file for the no-MP2 CGI version.

I'm stuck.  I could hack at inserting the ENV
variables in places, but I'd rather know where to
search for more clues first.

Tom


	
		
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

Re: MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate (check ORACLE_HOME and NLS settings)

Posted by Perrin Harkins <pe...@elem.com>.
On Tue, 2005-09-06 at 20:01 -0700, Thomas Hilbig wrote:
> It does not appear to be a permissions problem (I've
> run the httpd as User oracle), but turning on DBI
> tracing the problem does look like an environment
> variable problem. The ORACLE_HOME and other
> environment variables are not getting passed to DBI
> under mod_perl.

See PerlPassEnv:
http://perl.apache.org/docs/1.0/guide/config.html#PerlSetEnv_and_PerlPassEnv

- Perrin


Re: MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate (check ORACLE_HOME and NLS settings)

Posted by Thomas Hilbig <th...@yahoo.com>.
--- Praveen Ray <pr...@yahoo.com> wrote:

> --- Perrin Harkins <pe...@elem.com> wrote:
> 
> > On Tue, 2005-09-06 at 06:23 -0700, Thomas Hilbig
> wrote:
> > > I am struggling with a (simple?) DBI problem
> under MP2
> > > on Fedora Core 3.  A script that uses Oracle-DBI
> works
> > > under regular CGI but fails under MP2 with the
> > > following error:
> > > 
> > >   ERROR OCIEnvNlsCreate (check ORACLE_HOME and
> NLS
> > > settings etc.)
> > 
> > This has always turned out to be either not
> exporting
> > environment
> > variables correctly or permissions problems for
> me. 
> > Double-check your
> > permissions by trying to read the required Oracle
> files
> > as user
> > "nobody."  If you post your config file, someone
> may be
> > able to spot the
> > problem.
> > 
> 
> You can try something like :
> 
> PerlSetVar ORACLE_HOME  /home/oracle/oracle10g
> 
> or something similar instead of relying upon
> ORACLE_HOME
> getting exported from the startup shell.
> 
>   - Praveen  
> 

It does not appear to be a permissions problem (I've
run the httpd as User oracle), but turning on DBI
tracing the problem does look like an environment
variable problem. The ORACLE_HOME and other
environment variables are not getting passed to DBI
under mod_perl.

As you can see, in httpd.conf and the cgi script
itself I am trying everything to set the ORACLE_HOME
environment variables.  However, in the dbitrace.log
file, it appears nothing has worked.  The same script
works under a normal CGI (no mp2) and the dbitrace.log
file shows a healthy set of environment variables. 
This looks so simple; why aren't my environment
variables kept under mp2?

Thanks, Tom

httpd.conf (snip)=======================
LoadModule perl_module modules/mod_perl.so
SetEnv     "NLS_LANG" "AMERICAN_AMERICA.UTF8"
PerlSetEnv "NLS_LANG" "AMERICAN_AMERICA.UTF8"
SetEnv     ORACLE_HOME
"/home/oracle/product/10.2.0/db_1"
PerlSetEnv ORACLE_HOME
"/home/oracle/product/10.2.0/db_1"
SetEnv     LD_LIBRARY_PATH
/home/oracle/product/10.2.0/db_1/lib
PerlSetEnv LD_LIBRARY_PATH
/home/oracle/product/10.2.0/db_1/lib
SetEnv     ORACLE_SID tomdb1
PerlSetEnv ORACLE_SID tomdb1
ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
<Directory "/usr/local/apache2/cgi-bin">
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    Options +ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

tomdb1test.pl (CGI script) =====================
#!/usr/bin/perl
  use DBI ;
  use strict ;
  my ($dbh) ;
  $|=1 ;
  
# This is a CGI script. Debugging problem with modperl
 
$ENV{ORACLE_HOME}='/home/oracle/product/10.2.0/db_1';
  $ENV{'ORACLE_SID'}="tomdb1";
 
$ENV{'LD_LIBRARY_PATH'}="/home/oracle/product/10.2.0/db_1/lib";
  $ENV{'LD_ASSUME_KERNEL'} = "2.4.1" ;
  $ENV{'LD_PRELOAD'} =
"/usr/lib/libInternalSymbols.so" ;
  $ENV{'NLS_LANG'}=  "AMERICAN_AMERICA.UTF8" ;
  $ENV{'TNS_ADMIN'}=  "/home/oracle" ;

  # unlink '/tmp/dbitrace.log' if -e
'/tmp/dbitrace.log' ;
  DBI->trace( 16, '/tmp/dbitrace.log' ) ;
  print "Content-type: text/plain\n\n";

# Print out the Environment and @INC
  my $lineCount = 1 ;
  foreach my $var (sort(keys(%ENV))) {
    my $val = $ENV{$var};
    $val =~ s|\n|\\n|g;
    $val =~ s|"|\\"|g; 
    print "[$lineCount] ${var}=\"${val}\"\n";
    $lineCount++ ;
  }
  print  "\@INC = ", join("\n       ", @INC), "\n" ;

# Log into Oracle
  eval {
    $dbh =
DBI->connect("dbi:Oracle:host=redhat;sid=tomdb1;port=1521",
'scott', 'tiger') || die "Database Connect Failed: $@
\n $DBI::errstr\n";
  } ;
  if($@) {
    print "Connection to Oracle Failed: $@ \n";
  } else {
      print "Connection to Oracle Successful\n" ;
    $dbh->disconnect;
  }

dbitrace.log ==================================
  Environment variables:
        LANG=C
        TERM=xterm
       
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
        PWD=/
        SHLVL=1
        _=/sbin/initlog
       
OCINlsEnvironmentVariableGet(1,0,93,0,2)=SUCCESS
       
OCINlsEnvironmentVariableGet(1,0,94,0,2)=SUCCESS
       
OCINlsEnvCreate(9361cd4,3,0,0,0,0,0,0,1,1)=ERROR
         DESTROY for DBI::db=HASH(0x91ba654) ignored -
handle not initialised


	
		
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

Re: MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate (check ORACLE_HOME and NLS settings)

Posted by Praveen Ray <pr...@yahoo.com>.
--- Perrin Harkins <pe...@elem.com> wrote:

> On Tue, 2005-09-06 at 06:23 -0700, Thomas Hilbig wrote:
> > I am struggling with a (simple?) DBI problem under MP2
> > on Fedora Core 3.  A script that uses Oracle-DBI works
> > under regular CGI but fails under MP2 with the
> > following error:
> > 
> >   ERROR OCIEnvNlsCreate (check ORACLE_HOME and NLS
> > settings etc.)
> 
> This has always turned out to be either not exporting
> environment
> variables correctly or permissions problems for me. 
> Double-check your
> permissions by trying to read the required Oracle files
> as user
> "nobody."  If you post your config file, someone may be
> able to spot the
> problem.
> 

You can try something like :

PerlSetVar ORACLE_HOME  /home/oracle/oracle10g

or something similar instead of relying upon ORACLE_HOME
getting exported from the startup shell.

  - Praveen  


	
		
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

Re: MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate (check ORACLE_HOME and NLS settings)

Posted by Perrin Harkins <pe...@elem.com>.
On Tue, 2005-09-06 at 06:23 -0700, Thomas Hilbig wrote:
> I am struggling with a (simple?) DBI problem under MP2
> on Fedora Core 3.  A script that uses Oracle-DBI works
> under regular CGI but fails under MP2 with the
> following error:
> 
>   ERROR OCIEnvNlsCreate (check ORACLE_HOME and NLS
> settings etc.)

This has always turned out to be either not exporting environment
variables correctly or permissions problems for me.  Double-check your
permissions by trying to read the required Oracle files as user
"nobody."  If you post your config file, someone may be able to spot the
problem.

- Perrin


Re: MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate - MOSTLY SOLVED

Posted by Thomas Hilbig <th...@yahoo.com>.
--- Geoffrey Young <ge...@modperlcookbook.org> wrote:
> 
> DBD::Oracle needs these variables when DBD::Oracle
> is loaded.  which means
> they need to be in %ENV _before_ the script that
> first use()s DBD::Oracle is
> loaded.  httpd.conf is generally too late if you
> preload your modules via a
> startup.pl, or a module you PerlModule itself
> somehow loads it.
> 
> the typical way to do this is to place something
> like the following in your
> startup.pl
> 

Problem mostly resolved.  

I was checking my init.d settings (/etc/init.d/httpd)
to make sure everything was pointing at the correct
httpd environment.  All was fine, however, I happended
to notice that I got different results depending if I
used _service_ or called /etc/init.d/httpd directly:

  service httpd start  (mod_perl lost ENV settings)
  /etc/init.d/httpd start (worked fine in mod_perl)

In the first method, the only ENV variables that made
it to the dbitrace.log file were those set and
exported in /etc/init.d/functions .  Setting them in
httpd.conf or via a startup.pl didn't seem to help,
but I will experiment further.

Thanks for everyone's help on this,
Tom

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate (check ORACLE_HOME and NLS settings)

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> I've tried setting every standard Oracle environment
> variable in both httpd.conf (even using both SetEnv
> and PerlSetEnv) and in the script itself (NLS_LANG,
> ORACLE_HOME, LD_LIBRARY_PATH, ORACLE_SID).  What am I
> missing? 

DBD::Oracle needs these variables when DBD::Oracle is loaded.  which means
they need to be in %ENV _before_ the script that first use()s DBD::Oracle is
loaded.  httpd.conf is generally too late if you preload your modules via a
startup.pl, or a module you PerlModule itself somehow loads it.

the typical way to do this is to place something like the following in your
startup.pl

  BEGIN {
    $ENV{ORACLE_HOME} = ...
  }

  use DBD::Oracle;

see recipe 2.9 in the mod_perl developer's cookbook as a reference, if you like.

HTH

--Geoff

MP2 - DBI Problem only under mod_perl: OCIEnvNlsCreate (check ORACLE_HOME and NLS settings)

Posted by Thomas Hilbig <th...@yahoo.com>.
Hi,

I am struggling with a (simple?) DBI problem under MP2
on Fedora Core 3.  A script that uses Oracle-DBI works
under regular CGI but fails under MP2 with the
following error:

  ERROR OCIEnvNlsCreate (check ORACLE_HOME and NLS
settings etc.)

My test script dumps out the environment varables and
then attempts to connect to the Oracle server.  Other
than the DBI/Oracle error and a few extra MP2-specific
variable that MP2 creates, the output of the script is
identical on the CGI and MP2 versions.

I've tried setting every standard Oracle environment
variable in both httpd.conf (even using both SetEnv
and PerlSetEnv) and in the script itself (NLS_LANG,
ORACLE_HOME, LD_LIBRARY_PATH, ORACLE_SID).  What am I
missing? I don't beleive it is a permissions problem
as I've tried running the httpd server as User oracle,
with no difference.

I know this isn't a DBI mail group, but the probem
only occurs under MP2 so I think it is more of an
environment/setup problem.  It is a new system, so
everything is installed fresh (all apache/modperl
stuff added after FC3 install).

 httpd: 2.0.54
 MP2: 2.0.1
 Fedora Core 3: 2.6.12-1.1376_FC3 
 Oracle: 10g Release 2 (10.2.0)
 DBI - 1.48
 DBD::Oracle 1.16

Thanks, Tom



	
		
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

Re: Apache::Test not finding global config file

Posted by William McKee <wi...@knowmad.com>.
On Wed, Aug 31, 2005 at 06:19:10PM -0400, Geoffrey Young wrote:
> if you can do me the favor of trying a few different configuration scenarios
> (including 1.3, non-apxs, /usr/local/apache, etc) and making sure nothing
> breaks, that would be great.  the box where my matrix used to live had a
> hard drive failure, so I'm slowly rebuilding it as I find the time.

Besides testing under Apache2, I've tested with /usr/local/apache (this
was an Apache1 server and was non-apxs). That's all I have at my
disposal.


> I've been thinking a bit about this and I think the attached is a better
> patch.  basically, I think A-T goes through a lot of effort to separate the
> current filesystem configuration from the hard-coded stuff in httpd in an
> effort to make it easy to roll up an httpd install, move it someplace else,
> and still have A-T be able to create a worthy configuration.  using
> HTTPD_ROOT like that kinda breaks all of that for people expecting the
> current behavior, so I'd rather use it as a last-ditch effort than off the bat.
> 
> can you give it a whirl?

I removed your original patch and added this one then tested it under
the two systems above. Looks good.


Thanks,
William

-- 
Knowmad Services Inc.
http://www.knowmad.com

Re: Apache::Test not finding global config file

Posted by William McKee <wi...@knowmad.com>.
On Wed, Aug 31, 2005 at 06:19:10PM -0400, Geoffrey Young wrote:
> if you can do me the favor of trying a few different configuration scenarios
> (including 1.3, non-apxs, /usr/local/apache, etc) and making sure nothing
> breaks, that would be great.  the box where my matrix used to live had a
> hard drive failure, so I'm slowly rebuilding it as I find the time.

Besides testing under Apache2, I've tested with /usr/local/apache (this
was an Apache1 server and was non-apxs). That's all I have at my
disposal.


> I've been thinking a bit about this and I think the attached is a better
> patch.  basically, I think A-T goes through a lot of effort to separate the
> current filesystem configuration from the hard-coded stuff in httpd in an
> effort to make it easy to roll up an httpd install, move it someplace else,
> and still have A-T be able to create a worthy configuration.  using
> HTTPD_ROOT like that kinda breaks all of that for people expecting the
> current behavior, so I'd rather use it as a last-ditch effort than off the bat.
> 
> can you give it a whirl?

I removed your original patch and added this one then tested it under
the two systems above. Looks good.


Thanks,
William

-- 
Knowmad Services Inc.
http://www.knowmad.com