Do CGI and mod_perl play nicely together?
I've got an apache web server (without mod_perl) that's been running just fine for a long time. It has been suggested that we use mod_perl to improve the performance of some scripts.
I want to go ahead and install mod_perl on the server, which seems to be a relatively straightforward process, but I'm confused by some of the stuff coming up on Google searches. If I install mod_perl (through the debian repositories), will all of my existing CGIs suddenly start "using mod_perl" and exhibiting potentially wonky behavior?
Or is there some configuration in apache that needs to be done for an old CGI to "start using mod_perl"?
Apologies if this is a straightforward answer but I am confused by the terminology being used in mul开发者_如何学运维tiple ways in the documentation.
mod_perl has to be configured in your httpd.conf to be enabled. So not every script on your server will start to use mod_perl automatically.
Usually, you enable mod_perl per VHost. A usual configuration of mod_perl for a vhost looks like this:
<VirtualHost some.funny-domain.com>
ServerName some.funny-domain.com
ServerAdmin admin@funny-domain.com
DocumentRoot /data/path/to/root/
Perlrequire /data/path/to/startup.pl
PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload
PerlModule Apache2::RequestRec
ScriptAlias /cgi-bin/ "/data/path/to/root/cgi-bin/"
<Location /cgi-bin/>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
PerlOptions +SetupEnv
Options +ExecCGI
</Location>
CustomLog logs/access.log combined
ErrorLog logs/error.log
</VirtualHost>
Be carefull with the automated install-process! It may enable mod_perl on the wrong host for some reason! BackUp your config and apache-installation first to be able to "roll back" easily.
Comment: The line "Perlrequire /data/path/to/startup.pl" is not required. It is optional and sets some environment variables for the running scripts under the mod_perl env.
精彩评论