Use mod_perl
Mod_perl Is About module Apache realizing Perl the interpreter + set Perl of modules, giving the following interesting opportunities:
1. Caching otkompilirovanykh cgi scripts (Apache:: Registry.pm)
2. Perl the interface to C API Apache
The majority of developers use mod_perl to increase productivity of the scripts - Apache does not start new process at each search to script.pl since has now the Perl the interpreter, and does not compile script.pl at each search since Apache:: Registry.pm stores{keeps} yours otkompilirovanye scripts in a cache. Perl the interface to C API Apache is used by developers not so often.
As it looks - typical use mod_perl.
We have compiled Apache with support mod_perl, at us is script.pl:
*!/usr/bin/perl
use strict;
use CGI qw (:cgi);
print header (), ' Hi, people! ';
And we want, that the script was carried out by the interpreter mod_perl and kehshirovalsja. For this purpose we change httpd.conf:
* It we zakommentiruem
**** ScriptAlias/cgi-bin/«/home/my-project.ru/cgi-bin / »
* And it we shall add
PerlModule Apache:: Registry
<Location/cgi-bin> SetHandler perl-script PerlHandler Apache:: Registry
Options ExecCGI
allow from all
</Location>
Let's restart Apache and we shall be convinced, that all works.
Konfigurirovanie mod_perl.
Let's understand with that, that we have written in httpd.conf.
Mod_perl Defines{Determines} Apache handler with a name "perl-script". The following recording:
<Location/cgi-bin> SetHandler perl-script </Location>
Means, that searches to/cgi-bin will be processed with a code mod_perl.
Mod_perl Defines{Determines} also some directives:
PerlModule Some:: Module Other:: Module
- The directive loads ukazanye Perl modules. The scripts which are carried out under mod_perl, can use them, not switching function use (). From the point of view of a script, use PerlModule differs from use () that, that in a script does not import names of the module. The module, zagruzhenyj PerlModule, can be used also as obrabotchik any phase of processing of search, see below.
Perl*Handler Some:: Module
- Apache processes search in some phases - (Post-Read-Request, URI Translation, Header Parsing, Access Control, Authentication, Authorization, MIME type checking, FixUp, Response (!), Logging, Cleanup). Perl*Handler directive the module - obrabotchik for any from these phases. Most often PerlHandler directive establishing{installing} obrabotchik for phase Response is used. The others Perl*Handler directives (PerlPostReadRequestHandler, PerlTransHandler, PerlHeaderParserHandler, PerlAccessHandler, PerlAuthenHandler, …) are used less often.
In ours httpd.conf we have specified Apache:: Registry.pm as obrabotchik phases Response. When we require script.pl at the server, Apache:: Registry.pm takes otkompilirovanuju the version of a script from the cache and starts. Apache:: Registry.pm traces changes script.pl on a disk and if necessary perekompiliruet it{him}. However changes in the modules included script.pl are not traced are for a long time. So if you have changed any of the modules, restart the server.
You, certainly, are not obliged to use Apache:: Registry.pm as do{make} the majority of developers. Write for the sake of interest the obrabotchik phases Response:
package MyOwnResponseGenerator;
use strict;
use Apache:: Constants qw (:common);
sub handler {
print « Content-type: text/htmlnn »;
print « Hi people! enjoy this response! »;
return OK; * We must return a status to mod_perl
}
1;
MyOwnResponseGenerator.pm We shall put there where mod_perl can find it{him} (perl-e ' print join "n" e;, @INC '). We shall edit httpd.conf:
PerlModule MyOwnResponseGenerator
<Location/somelocation>
SetHandler perl-script PerlHandler MyOwnResponseGenerator
PerlSendHeader On
</Location>
Let's restart Apache, we shall type{collect} http: // my-project.ru/somelocation. Works!
In detail about konfigurirovanii mod_perl:
http://perl.apache.org/docs/1.0/guide/config.html

|