Re: perl in configs /perl

2000-04-21 Thread w trillich

sorry i haven't been clearer about this:

with a few inserted debug statements (say, printing
the string to my tty directly) i can tell that the perl
code gets executed.

but no apache settings are affected. ZERO effect on apache.
doesn't act as if its done a damn thing. apache ignores it
even though it executes. the only settings it goes by
are the ones in the httpd.conf/srm.conf/access.conf files
which existed before/after (independent of) this script
being called.


package Apache::ReadConfig; # in case that isn't set

my $set = "END_SETTINGS";
VirtualHost xxx.yyy.zzz.qqq
ServerAdmin webmaster\@$host
DocumentRoot $docroot
ServerName $host
DirectoryIndex index # index.html index.cgi
CustomLog $logroot/access.log common
CustomLog $logroot/referer.log referer
CustomLog $logroot/agent.log agent
ScriptLog $logroot/scriptDebug.log

@{[join "", map THIS, qw(/cgi-bin/ /cgi/)]}
ScriptAlias $_ /usr/lib/cgi-bin
THIS
/VirtualHost
END_SETTINGS

Apache-httpd_conf($set);

__END__

that's basically the script (with the variables filled in, 
inside a loop, of course). 

# apachectl configtest
Syntax OK
# apachectl graceful
# 

so i go to my browser and try going to one of my virtual
hosts:
http://virtual1.myhost.com/
and instead of the files at the proper docroot, i get
http://www.myhost.com/
files--i.e. apache has gotten no virtual host directive.
none.

so forget that i looked for useful data under /server-info
and /perl-status... the fact that it matches the apache
setup (i.e. IT'S WRONG) seemed to be a reasonably accurate
report of a screwy situation.

THE PERL CODE IS RUNNING, BUT *NOT* AFFECTING ANY APACHE SETTINGS.

do i need to write the string to a file and then INCLUDE
it in the httpd.conf file after the script runs?

feels like i have issued a directive in access.conf that disables
perl sections (or 'do "file.pl"') scripts for taking any effect.
or, there's a directive within the perl code that's missing.

help!



Re: perl in configs /perl

2000-04-20 Thread Doug MacEachern

 but localhost/server-info shows no such directive having
 taken effect...

mod_info does it's own parsing of httpd.conf, it does not understand 
Perl sections.




Re: perl in configs /perl

2000-04-19 Thread J. J. Horner

On Wed, 19 Apr 2000, w trillich wrote:

 having seen the possibilities from
 /usr/share/doc/libapache-mod-perl/examples/perl_sections.txt
 (schwartz's neat virtual host setup) i thought i'd give it
 a whirl.
 

I don't have this.  Can someone point me to a link, or maybe send it via
email to either [EMAIL PROTECTED] or [EMAIL PROTECTED]?

J. J. Horner




Re: perl in configs /perl

2000-04-19 Thread Stas Bekman

On Wed, 19 Apr 2000, J. J. Horner wrote:

 On Wed, 19 Apr 2000, w trillich wrote:
 
  having seen the possibilities from
  /usr/share/doc/libapache-mod-perl/examples/perl_sections.txt
  (schwartz's neat virtual host setup) i thought i'd give it
  a whirl.
  
 
 I don't have this.  Can someone point me to a link, or maybe send it via
 email to either [EMAIL PROTECTED] or [EMAIL PROTECTED]?

mod_perl-x.xx/eg/perl_sections.txt
and this was written by Rob Hartill and not Randal, unless we are talking
about different files.

As for the original question from w trillich [EMAIL PROTECTED], here is
a rewritten not yet released section about Perl section that might solve
your problem. The most relevant to the question sections are 'Caveats',
'Verifying' and 'Debugging':

=head1 Apache Configuration in Perl

With CPerl...C/Perl sections, it is possible to configure your
server entirely in Perl.

=head2 Usage

CPerl sections can contain Iany and as much Perl code as you
wish. These sections are compiled into a special package whose symbol
table mod_perl can then walk and grind the names and values of Perl
variables/structures through the Apache core configuration gears.
Most of the configuration directives can be represented as scalars
(C$scalar) or lists (C@list).  A C@List inside these sections is
simply converted into a space delimited string for you. Here is an
example:

   httpd.conf
  
  Perl
  @PerlModule = qw(Mail::Send Devel::Peek);
  
  #run the server as whoever starts it
  $User  = getpwuid($) || $;
  $Group = getgrgid($)) || $); 
  
  $ServerAdmin = $User;
  
  /Perl

Block sections such as CLocation..C/Location are represented
in a C%Location hash, e.g.:

  Perl
  
  $Location{"/~dougm/"} = {
AuthUserFile = '/tmp/htpasswd',
AuthType = 'Basic',
AuthName = 'test',
DirectoryIndex = [qw(index.html index.htm)],
Limit = {
  METHODS = 'GET POST',
  require = 'user dougm',
},
  };
  
  /Perl

If an Apache directive can take two or three arguments you may push
strings (the lowest number of arguments will be shifted off the
C@List) or use an array reference to handle any number greater than
the minimum for that directive:

  push @Redirect, "/foo", "http://www.foo.com/";
  
  push @Redirect, "/imdb", "http://www.imdb.com/";
  
  push @Redirect, [qw(temp "/here" "http://www.there.com")];

Other section counterparts include C%VirtualHost, C%Directory and
C%Files.

To pass all environment variables to the children with a single
configuration directive, rather than listing each one via CPassEnv
or CPerlPassEnv, a CPerl section could read in a file and:

  push @PerlPassEnv, [$key = $val];

or

  Apache-httpd_conf("PerlPassEnv $key $val");

These are somewhat simple examples, but they should give you the basic
idea. You can mix in any Perl code you desire. See Ieg/httpd.conf.pl
and Ieg/perl_sections.txt in the mod_perl distribution for more
examples.

Assume that you have a cluster of machines with similar configurations
and only small distinctions between them: ideally you would want to
maintain a single configuration file, but because the configurations
aren't Iexactly the same (e.g. the CServerName directive) it's not
quite that simple.

CPerl sections come to rescue. Now you have a single configuration
file and the full power of Perl to tweak the local configuration. For
example to solve the problem of the CServerName directive you might
have this CPerl section:

  Perl
  $ServerName = `hostname`;
  /Perl

For example if you want to allow personal directories on all machines
except the ones whose names start with Isecure:

  Perl
  $ServerName = `hostname`;
  if ( $ServerName !~ /^secure/) {
$UserDir = "public.html";
  } else {
$UserDir = "DISABLED";
  }
  /Perl


Behind the scenes, mod_perl defines a package called
CApache::ReadConfig.  Here it keeps all the variables that you
define inside the CPerl sections. Therefore it's not necessarily
to configure the server within the CPerl sections. Actually what
you can do is to write the Perl code to configure the server just like
you'd do in the CPerl sections, but instead place it into a
separate file that should be called during the configuration parsing
with either CPerlModule or CPerlRequire directives, or from within
the startup file. All you have to do is to declare the package
CApache::ReadConfig within this file. Using the last example:

  apache_config.pl
   
  package Apache::ReadConfig;
  
  $ServerName = `hostname`;
  if ( $ServerName !~ /^secure/) {
$UserDir = "public.html";
  } else {
$UserDir = "DISABLED";
  }
  
  1;

  httpd.conf
  --
  PerlRequire /home/httpd/perl/lib/apache_config.pl




=head2 Enabling

To enable CPerl sections you should build mod_perl with Sperl
Makefile.PL PERL_SECTIONS=1 [ ... ].


=head2 Caveats

Be careful when you declare package names inside CPerl sections,
for example this code has a problem:

  Perl  
package My::Trans;
use 

Re: perl in configs /perl

2000-04-19 Thread Stas Bekman

 i've seen the manpages for mod_perl -- your rendition has
 a bit more flesh to it, but my comprehension still suffers
 the same problem schwartz complained about (also in the
 same file as the example i quoted, namely
 /usr/share/doc/libapache-mod-perl/examples/perl_sections_2.txt.gz
 from debian distribution 2.1/2.2)

Well, I've posted the rewrited section and stressed to read the Caveats
section for a reason. If you reread it or the file that you've just
forwarded you will see that you miss:

package Apache::ReadConfig; 

in your file.

And the same text I've forwarded explains how to debug the section when in
problem.

Hope this helps

BTW, please don't refer to a file with a full path on your system just
because it was installed there. It confuses people. The second file is at
the mod_perl dist at mod_perl-x.xx/eg/perl_sections_2.txt .

Enjoy!

__
Stas Bekman | JAm_pH--Just Another mod_perl Hacker
http://stason.org/  | mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]  | http://perl.orghttp://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
--




Re: perl in configs /perl KAPUT

2000-04-19 Thread w trillich

 In a running httpd you can see how you have configured the CPerl
 sections through the URI
 L/perl-status|debug/Apache_Status_Embedded_Inter, by choosing IPerl
 Section Configuration from the menu. In order to make this item show
 up in the menu you should set C$Apache::Server::SaveConfig to a true
 value. When you do that the IApache::ReadConfig namespace (in which
 the configuration data is stored) will not be flushed, making
 configuration data available to Perl modules at request time.

i must be thick today.

not only can i get no effect from perldo "file.pl"/perl but
http://localhost/perl-status|debug/Apache_Status_Embedded_Inter
gives me 404 not found. 

/perl-stat by itself works fine; from there i can tell the
PerlRequire (actually perldo "file"/perl) has been run.

i just want a couple simple virtual hosts on one ip number.

the perl code (under "package Apache::ReadConfig;" of course)
does run (i can tell by having it display the same string it
sends to Apache-httpd_conf()) but doesn't change any apache
settings.

if this helps, here's the display from
http://localhost/perl-status?ApacheReadConfig . . .
hashes
ApacheReadConfig::Directory,
ApacheReadConfig::DirectoryMatch,
ApacheReadConfig::Files,
ApacheReadConfig::FilesMatch,
ApacheReadConfig::Limit,
ApacheReadConfig::Location,
ApacheReadConfig::LocationMatch,
ApacheReadConfig::VirtualHost
ios
ApacheReadConfig::TTY

any clues?



Re: perl in configs /perl

2000-04-19 Thread w trillich

Stas Bekman wrote:
 
 I still don't know your name, so I'll just use 'you' :)

or trillich (or even 'will' on my birthday).

 First, please keep the replies posted to the list. We don't want to answer
 something more than once, when it goes to the list, someone will answer
 you and it'll be stored in the archive for other people use.
 
 So please repost your reply to the list.

whoops. 'reply' button is smarter than i am, at times.

   BTW, please don't refer to a file with a full path on your system just
   because it was installed there. It confuses people. The second file is at
   the mod_perl dist at mod_perl-x.xx/eg/perl_sections_2.txt .
 
  you've obviously not been sitting over my shoulder lately!
 
  i have spent days looking for examples referenced like that. some
  are under /usr/src which i don't have installed; others are
  under perl library module directories, others are in /usr/doc.
  talk about confusion! (in addition, /eg/ seems to be a
  low-keystroke way to refer to the actual directory, which is
  actually /examples/. very confusing.)
 
  plus, if i sought mod_perl i might not run into apache_mod_perl...
 
  so i figure it's easier for someone to decode a full pathname
  than to imagine and hope and conjure out of thin air which path
  to append...
 
 It's incorrect! The files are located in the *mod_perl distribution*, and
 they are located just where I've said and not where your binary
 distribution has happen to include them.
 
 You have been looking in all wrong places, you could ask the list first
 and even better to search the mailing list archives.

i try to do some background work before dumping my troubles
on other unsuspecting folk. but lemme tellya, looking for the
precise configuration file for the precise command is a lot
more taxing than just opening a control panel and clicking some
checkboxes and menus...

so how does one find out what the distribution pathname is
when all one has to go by is the installed set of files?
(lemme rephrase--the installed fileset is all i know of, to go by.)



and still apache ignores my perl 'Apache-httpd_conf($c);'...



Re: perl in configs /perl

2000-04-19 Thread Stas Bekman

  It's incorrect! The files are located in the *mod_perl distribution*, and
  they are located just where I've said and not where your binary
  distribution has happen to include them.
  
  You have been looking in all wrong places, you could ask the list first
  and even better to search the mailing list archives.
 
 i try to do some background work before dumping my troubles
 on other unsuspecting folk. but lemme tellya, looking for the
 precise configuration file for the precise command is a lot
 more taxing than just opening a control panel and clicking some
 checkboxes and menus...
 
 so how does one find out what the distribution pathname is
 when all one has to go by is the installed set of files?
 (lemme rephrase--the installed fileset is all i know of, to go by.)

It's easy to find, try to look under:  http://perl.apache.org/dist or even
if this is not obvious (of course you have to go to http://perl.apache.org
and click on the link) http://cpan.org is the right place to look for any
Perl modules distributions. 

__
Stas Bekman | JAm_pH--Just Another mod_perl Hacker
http://stason.org/  | mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]  | http://perl.orghttp://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
--