How do I make Apache handle .pl (Perl) files, using mod_perl?
Asked Answered
W

3

8

I'm using Apache 2. I know how to handle .pl files as "cgi-script", but mod_perl is supposedly way faster. I successfully built and installed mod_perl, but how do I change httpd.conf so that .pl files will be handled by mod_perl (and not as cgi-script)?

Williwaw answered 3/1, 2009 at 19:40 Comment(1)
This might help you: perl.apache.org/docs/2.0/user/config/config.htmlMesotron
S
7

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

Sommersommers answered 3/1, 2009 at 20:10 Comment(0)
T
2

The following is untested by myself and can 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 execute.

How I normally do it due to security:

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

The previous method will deny Directory Browsing if you need that, 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>
Tinytinya answered 17/5, 2011 at 21:49 Comment(0)
C
1

I'm fairly certain as long as you have the module loaded, you can just add a

AddHandler mod_perl .pl

Celesta answered 3/1, 2009 at 19:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.