How to get Apache to process .pl (Perl) files using mod_perl?

I use Apache 2. I know how to handle .pl files as a "cgi- script", but mod_perl is supposedly faster. I have successfully built and installed mod_perl, but how do I modify httpd.conf so that .pl files are processed by mod_perl (and not as a cgi- script)?

+7
perl apache mod-perl
source share
3 answers

How to do this is described in the mod_perl documentation here . In particular, read the "Registry Scripts" section.

+6
source share

The following has not been verified by me and may be added to an existing vhost directive file

PerlModule ModPerl::Registry <Files ~ "\.(pl|cgi)$"> SetHandler perl-script PerlResponseHandler ModPerl::Registry Options +ExecCGI PerlSendHeader On </Files> 

and then any .pl or .cgi files in any of your directories will be executed.

As I usually do for security reasons:

 PerlModule ModPerl::Registry <Directory /opt/myawesomescripts/> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI AllowOverride None </Directory> 

The previous method will strip Directory Browsing, if you need it, you should do something like this:

 PerlModule ModPerl::Registry <Directory /var/www/> Options FollowSymLinks MultiViews ExecCGI Indexes AddHandler perl-script .cgi .pl PerlResponseHandler ModPerl::Registry AllowOverride None Order allow,deny allow from all </Directory> 
+2
source share

I am sure that while you download the module, you can simply add

AddHandler mod_perl .pl

+1
source share

All Articles