简体   繁体   中英

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

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)?

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

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>

我相当肯定只要你加载了模块,你就可以添加一个

AddHandler mod_perl .pl

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM