Do CGI and mod_perl play nicely together?

喜你入骨 提交于 2019-12-22 13:59:57

问题


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 multiple ways in the documentation.


回答1:


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.



来源:https://stackoverflow.com/questions/7586897/do-cgi-and-mod-perl-play-nicely-together

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