On Jul 19, 2000 at 10:09:36 +0300, Alex Shnitman twiddled the keys to say:
> On Tue, Jul 18, 2000 at 11:30:44PM -0400, Rick Myers wrote:
> 
> > > Another interesting thing about this issue: if I assign
> > > $port{$portname} + 1 to $Port, and not just $port{$portname}, it
> > > works! If I ever try to return $Port to the needed value, e.g. using
> > > the -- operator, it doesn't work again. This completely stumps me. I
> > > tried just about any trick you can think of to get the value from
> > > $port{$portname} to $Port, but I can't -- if I add to it or substract
> > > from it, it's fine, but if it somehow gets back to the original value,
> > > in any way, it doesn't work again.
> > > 
> > > Does that give any new ideas as to the source of this issue?
> > 
> > Yes. The source of the issue is that you sent your ErrorLog to
> > /dev/null. Send it somewhere else where you can read it and you should
> > find the error in short order.
> 
> That's what I do in my configuration file -- I just trimmed it down to
> show just the code that matters in the sample that I sent to the list.
> 
> Here's the error I get in the error log:
> [Wed Jul 19 10:07:14 2000] [crit] (13)Permission denied: make_sock: could not bind 
>to port 80
> It couldn't bind to port 80 because another web server is running
> there. This means that it didn't recognize the $Port setting,
> although printing $Port from within the config file prints 8010
> properly. That's precisely the problem.

After fooling with this for several hours I've finally come to the
conclusion that this is probably an Apache "problem".

The quickest way to illustrate it is trying this <Perl> section...

   <Perl>
   my %port = ( zz => 8014 );
   warn "PORTHASH: $port\n";
   
   use POSIX ();
   my $portname = POSIX::getcwd();
   chomp $portname;
   warn "PORTNAME1: '$portname'\n";
   $portname =~ s:.*/::;
   warn "PORTNAME2: '$portname'\n";
   
   $Port = $port{$portname};
   warn "PORT: '$Port'\n";
   my $ppid = getppid;
   warn "PPID: $ppid\n";
   </Perl>

Now, try running your server as before, but make sure you have access to
the ErrorLog file. You'll notice that several of the warn()'s generate
completely different output in the error_log than they do on your shell
screen.

The first significant difference is that PORTNAME1 points to `/home/zz'
(or wherever you started httpd from) in your shell, while in the
error_log it points to `/'. I'd almost bet money that the conf file is
parsed the first time under your shell, then again after Apache has
disassociated itself, thus showing you seemingly valid output on the
shell.

If you then grep through the Apache source you'll find this in
src/main/http_main.c...

   static void detach(void)
   {
   #if !defined(WIN32) && !defined(NETWARE)
       int x;
   
       chdir("/");

Bingo!

Now the question is how to pass the proper directory name to mod_perl's
<Perl> sections. The answer lies subtly tucked away on p. 423 of the
Eagle book. Just add a PerlPassEnv to your conf file...

   PerlPassEnv PWD

Then use $ENV{PWD} instead of POSIX::getcwd() and you should be all set.

*whew*

Rick Myers                            [EMAIL PROTECTED]
----------------------------------------------------
The Feynman Problem       1) Write down the problem.
Solving Algorithm         2) Think real hard.
                          3) Write down the answer.

Reply via email to