8.20. Getting mod_perl to Handle All Perl Scripts
Problem
You want all .pl files to always be executed by mod_perl.
Solution
Place this line near the top of your httpd.conf file, after the module declaration and activation sections:
PerlModule Apache::Registry
Place this code in the section of your httpd.conf file which includes the scope where you want this behavior to occur (such as within a <Directory> container:
<FilesMatch \.pl$>
SetHandler perl-script
PerlHandler Apache::Registry
</FilesMatch>Be sure that you have the Apache module mod_perl installed and activated.
Discussion
The PerlModule directive
ensures that the necessary bits from mod_perl are available. The <FilesMatch>
applies to every file ending in .pl
and instructs the server to treat it as a script to be handled as CGI
scripts by the Apache::Registry
package.
More information can be found at the mod_perl Web site (http://perl.apache.org).
These directives will result in all .pl
files being treated as CGI scripts, whether they are or not. If the
server tries to execute a non-CGI script using this method, the
end-user will get an error page and an entry will be made in the
server’s error log. The most common error logged refers to “Premature end of script headers,” which is a
pretty sure indicator of either a broken CGI script or a completely
non-CGI script being treated like one.
See Also
The mod_perl Web site at http://perl.apache.org
mod_perl Developer’s Cookbook, by Geoffrey Young et al., which can be accessed at http://modperlcookbook.org/ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access