10.07.2015 Views

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

206CHAPTER 11 ■ DEVELOPMENT WITH MOD_PERL<strong>Perl</strong>RunOnceSometimes, even Apache::<strong>Perl</strong>Run by itself won’t fix the problems. In such instances, you canalso invoke <strong>Perl</strong>RunOnce option. <strong>With</strong> <strong>Perl</strong>RunOnce enabled, the process responsible for executingthe <strong>Perl</strong> program is spawned only for the lifetime of that execution and dies thereafter. Ifyou believe that this would cause nontrivial performance degradation, you are correct.You set the <strong>Perl</strong>RunOnce option from within the Apache configuration, specifically withinthe mod_perl section. Recall the sample configuration for Apache and mod_perl from Chapter 10,now modified <strong>to</strong> use Apache::<strong>Perl</strong>Run:SetHandler perl-script<strong>Perl</strong>Handler Apache::<strong>Perl</strong>RunOptions +ExecCGI<strong>Perl</strong>SendHeader OnAllow from allTo enable <strong>Perl</strong>RunOnce, you use the <strong>Perl</strong>SetVar option:<strong>Perl</strong>SetVar <strong>Perl</strong>RunOnce OnThe configuration now looks like this:SetHandler perl-script<strong>Perl</strong>Handler Apache::<strong>Perl</strong>Run<strong>Perl</strong>SetVar <strong>Perl</strong>RunOnce OnOptions +ExecCGI<strong>Perl</strong>SendHeader OnAllow from allApache::RegistryApache::Registry is the better performing module of the two modules discussed here forserving content through <strong>Perl</strong>Handler configuration directive. Examples shown throughout theremainder of this chapter will assume the use of Apache::Registry.Each program executed through Apache::Registry is done so by each Apache child,which compiles the program only once. This initial compile may result in the very first loadof a program taking incrementally longer before the subsequent runs take advantage of thatprecompile.The Apache configuration <strong>to</strong> mod_perl with Apache::Registry is typically as follows(replace /home/suehring/perl with the appropriate location for your installation):Alias /perl/ /home/suehring/perl/SetHandler perl-script<strong>Perl</strong>Handler Apache::Registry

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!