![]() |
Practical mod_perl / HTML Version / | ![]() |
||
![]() |
||||
![]() |
![]() |
|||
![]() |
![]() |
|||
![]() |
||||
|
|
||||
![]() |
![]() |
|||
![]() |
11.5. PerlSetupEnv |
![]() |
||
![]() |
||||
![]() |
![]() |
![]() |
||
![]() |
||||
By default, PerlSetupEnv is On, but PerlSetupEnv Off is another optimization you should consider.
mod_perl modifies the environment to make it appear as if the script were being called under the CGI protocol. For example, the $ENV{QUERY_STRING} environment variable is initialized with the contents of $r->args( ), and the value returned by $r->server_hostname( ) is put into $ENV{SERVER_NAME}.
But populating %ENV is expensive. Those who have moved to the mod_perl API no longer need this duplicated data and can improve performance by turning it off. Scripts using the CGI.pm module require PerlSetupEnv On because that module relies on the environment created by mod_cgi. This is yet another reason why we recommend using the Apache::Request module in preference to CGI.pm.
Note that you can still set environment variables when PerlSetupEnv is Off. For example, say you use the following configuration:
PerlSetupEnv Off
PerlModule Apache::RegistryNG
<Location /perl>
PerlSetEnv TEST hi
SetHandler perl-script
PerlHandler Apache::RegistryNG
Options +ExecCGI
</Location>
Now issue a request for the script shown in Example 11-2.
use Data::Dumper;
my $r = Apache->request( );
$r->send_http_header('text/plain');
print Dumper \%ENV;
You should see something like this:
$VAR1 = {
'GATEWAY_INTERFACE' => 'CGI-Perl/1.1',
'MOD_PERL' => 'mod_perl/1.26',
'PATH' => '/bin:/usr/bin:/usr... snipped ...',
'TEST' => 'hi'
};
Note that we got the value of the TEST environment variable we set in httpd.conf.
 
Continue to:
mod_perl, modperl, Apache, perl, cgi, html, mod_perl, e-commerce, scalability, free, open source, OSS, apache, squid, high availability, modperl, linux, unix, Web, www, mod_perl, webserver, admin, apache, book, webmaster, tools, modperl, guide, docs, documentation, help, mod_perl, perl, information, apache, script, errata, eric cholet, perl, apache, mod-perl, stas bekman, mod_perl, cool, perl, Apache, performance, speed, choice
![]() |
Other projects to check out: meta-religion.com is for those interested in Religious, Spiritual and Esoteric Phenomena. i-want-a-better.com is a community of people discussing what they would like to be improved in their lives and things they use and interact with. You may also want to find a healer in your area or read articles on variety of topics.