1docs::api::ModPerl::RegUissetrryC(o3n)tributed Perl Docudmoecnst:a:taipoin::ModPerl::Registry(3)
2
3
4

NAME

6       ModPerl::Registry - Run unaltered CGI scripts persistently under
7       mod_perl
8

Synopsis

10         # httpd.conf
11         PerlModule ModPerl::Registry
12         Alias /perl/ /home/httpd/perl/
13         <Location /perl>
14             SetHandler perl-script
15             PerlResponseHandler ModPerl::Registry
16             #PerlOptions +ParseHeaders
17             #PerlOptions -GlobalRequest
18             Options +ExecCGI
19         </Location>
20

Description

22       URIs in the form of "http://example.com/perl/test.pl" will be compiled
23       as the body of a Perl subroutine and executed.  Each child process will
24       compile the subroutine once and store it in memory. It will recompile
25       it whenever the file (e.g. test.pl in our example) is updated on disk.
26       Think of it as an object oriented server with each script implementing
27       a class loaded at runtime.
28
29       The file looks much like a "normal" script, but it is compiled into a
30       subroutine.
31
32       For example:
33
34         my $r = Apache2::RequestUtil->request;
35         $r->content_type("text/html");
36         $r->send_http_header;
37         $r->print("mod_perl rules!");
38
39       XXX: STOPPED here. Below is the old Apache::Registry document which I
40       haven't worked through yet.
41
42       META: document that for now we don't chdir() into the script's dir,
43       because it affects the whole process under threads.
44       "ModPerl::RegistryPrefork" should be used by those who run only under
45       prefork MPM.
46
47       This module emulates the CGI environment, allowing programmers to write
48       scripts that run under CGI or mod_perl without change.  Existing CGI
49       scripts may require some changes, simply because a CGI script has a
50       very short lifetime of one HTTP request, allowing you to get away with
51       "quick and dirty" scripting.  Using mod_perl and ModPerl::Registry
52       requires you to be more careful, but it also gives new meaning to the
53       word "quick"!
54
55       Be sure to read all mod_perl related documentation for more details,
56       including instructions for setting up an environment that looks exactly
57       like CGI:
58
59        print "Content-type: text/html\n\n";
60        print "Hi There!";
61
62       Note that each httpd process or "child" must compile each script once,
63       so the first request to one server may seem slow, but each request
64       there after will be faster.  If your scripts are large and/or make use
65       of many Perl modules, this difference should be noticeable to the human
66       eye.
67

DirectoryIndex

69       If you are trying setup a DirectoryIndex under a Location covered by
70       ModPerl::Registry* you might run into some trouble.
71
72       META: if this gets added to core, replace with real documenation.  See
73       http://marc.theaimsgroup.com/?l=apache-modperl&m=112805393100758&w=2
74

Special Blocks

76   "BEGIN" Blocks
77       "BEGIN" blocks defined in scripts running under the "ModPerl::Registry"
78       handler behave similarly to the normal mod_perl handlers plus:
79
80       ·   Only once, if pulled in by the parent process via
81           "Apache2::RegistryLoader".
82
83       ·   An additional time, once per child process or Perl interpreter,
84           each time the script file changes on disk.
85
86       "BEGIN" blocks defined in modules loaded from "ModPerl::Registry"
87       scripts behave identically to the normal mod_perl handlers, regardless
88       of whether they define a package or not.
89
90   "CHECK" and "INIT" Blocks
91       Same as normal mod_perl handlers.
92
93   "END" Blocks
94       "END" blocks encountered during compilation of a script, are called
95       after the script has completed its run, including subsequent
96       invocations when the script is cached in memory. This is assuming that
97       the script itself doesn't define a package on its own. If the script
98       defines its own package, the "END" blocks in the scope of that package
99       will be executed at the end of the interpretor's life.
100
101       "END" blocks residing in modules loaded by registry script will be
102       executed only once, when the interpreter exits.
103

Security

105       "ModPerl::Registry::handler" performs the same sanity checks as mod_cgi
106       does, before running the script.
107

Environment

109       The Apache function `exit' overrides the Perl core built-in function.
110

Commandline Switches In First Line

112       Normally when a Perl script is run from the command line or under CGI,
113       arguments on the `#!' line are passed to the perl interpreter for
114       processing.
115
116       "ModPerl::Registry" currently only honors the -w switch and will enable
117       the "warnings" pragma in such case.
118
119       Another common switch used with CGI scripts is -T to turn on taint
120       checking.  This can only be enabled when the server starts with the
121       configuration directive:
122
123        PerlSwitches -T
124
125       However, if taint checking is not enabled, but the -T switch is seen,
126       "ModPerl::Registry" will write a warning to the error_log file.
127

Debugging

129       You may set the debug level with the $ModPerl::Registry::Debug bitmask
130
131        1 => log recompile in errorlog
132        2 => ModPerl::Debug::dump in case of $@
133        4 => trace pedantically
134

Caveats

136       ModPerl::Registry makes things look just the CGI environment, however,
137       you must understand that this *is not CGI*.  Each httpd child will
138       compile your script into memory and keep it there, whereas CGI will run
139       it once, cleaning out the entire process space.  Many times you have
140       heard "always use "-w", always use "-w" and 'use strict'".  This is
141       more important here than anywhere else!
142

Authors

144       Andreas J. Koenig, Doug MacEachern and Stas Bekman.
145

See Also

147       "ModPerl::RegistryCooker", "ModPerl::RegistryBB" and
148       "ModPerl::PerlRun".
149
150
151
152perl v5.12.0                      2007-11-12   docs::api::ModPerl::Registry(3)
Impressum