15.6 Perl Sections

directives (Apache), mod_perl module, perl directives, Apache server, mod_perl with">

Team-Fly    

 
Webmaster in a Nutshell, 3rd Edition
By Robert Eckstein, Stephen Spainhour
Table of Contents
Chapter 15.  Web Server Programming with mod_perl

15.6 <Perl> Sections

With mod_perl, you can use Perl in Apache configuration files. This means you can make your Apache configuration much more flexible by using conditionals.

Any Perl code in Apache configuration files should be placed between <Perl> and </Perl> directives. This code can define variables and lists used by mod_perl to assign the associated Apache configuration directives; for example, assigning the $ServerAdmin variable redefines the ServerAdmin Apache configuration directive.

Suppose you share the same Apache configuration files across multiple servers, and you only want to allow personal directories on one of them. You can use Perl directives like this:

 <Perl> if (`hostname` =~ /public/) {         $UserDir = "public.html"; } else {         $UserDir = "DISABLED"; } 1; </Perl> 

Directive blocks (such as <Location>...</Location>) can be represented as a hash:

 <Perl> $Location{"/design_dept/"} = {         DefaultType   => 'image/gif', FancyIndexing => 'On' } </Perl> 

Team-Fly    
Top


Webmaster in a Nutshell
Webmaster in a Nutshell, Third Edition
ISBN: 0596003579
EAN: 2147483647
Year: 2002
Pages: 412

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net