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

两盒软妹~` 提交于 2019-12-22 05:06:16

问题


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


回答1:


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




回答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>



回答3:


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

AddHandler mod_perl .pl



来源:https://stackoverflow.com/questions/409686/how-do-i-make-apache-handle-pl-perl-files-using-mod-perl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!