I am setting up a
server so that all my scripts have .cgi extentions. It would be nice if I
could just add some directives in the httpd.conf that will have all my virtual
hosts use modPerl for any files with either a .pl or a .cgi extention. The
reason I prefer this method is that I have a couple scripts that I load in my
httpdocs directory (the site home page is a script) So this is what I
did:
Commented out:
AddHandler cgi-script .cgi
Added the
following:
<IfModule
mod_perl.c>
<Files ~ (\.pl|\.cgi)>
SetHandler perl-script
PerlHandler Apache::PerlRun
<Files ~ (\.pl|\.cgi)>
SetHandler perl-script
PerlHandler Apache::PerlRun
Options
+ExecCGI
allow from all
PerlSendHeader On
</Files>
</IfModule>
allow from all
PerlSendHeader On
</Files>
</IfModule>
What I found is that
when I only had this code only outside of the VirtualHost configurations, my
test script indicated .pl was running in modPerl but .cgi wasn't. I only
could get .cgi to run in mod_Perl by copying this code inside of each of
the VirtualHost configurations.
Obviously I'm not an
Apache config expert but one thing that also struck me strange is that while
this code clearly indicates how to handle .pl and .cgi file extentions, prior to
adding this, I could not find anywhere in httpd.conf where it maps .cgi files in
this same way. The only code I could find is AddHandler cgi-script .cgi
but shouldn't there be some additional corresponding code like PerlHandler
Appache::Mod_CGI, Options +ExecCGI, etc.?? Also, how does appache know
which module to use for ScriptAlias directories? I left the ScriptAlias
directives in for the cgi-bin director and didn't change them to just Alias
directives and it works fine but I guess that means a filematch directive
overrides a ScriptAlias directive?
A bit
confused. Anyway, is the above method for achieving what I want an
acceptable and secure/safe way to handle it?
Thanks