读取Mod_Perl模块的文档,我们可以configuration它在每个域的基础上,我的意思是我们可以configuration它只在每个域或特定的域上运行。
我在文档中看到的是:
registry脚本
要启用registry脚本,请添加到httpd.conf中:
Alias /perl/ /home/httpd/2.0/perl/ <Location /perl/> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI </Location>
现在假设我们有以下脚本:
- 将所有页面mod_rewrite复制到一个脚本
- 尝试访问php5.3网站时没有日志信息的Apache Error 500
- 任何人在亚马逊Linux AMI上成功安装zend server CE?
- apt-get子stream程返回错误代码(1)
- SSL代理:转发没有encryption
#!/usr/bin/perl print "Content-type: text/plain\n\n"; print "mod_perl 2.0 rocks!\n";
保存在/home/httpd/httpd-2.0/perl/rock.pl。 使脚本可执行,并可由大家阅读:
% chmod a+rx /home/httpd/httpd-2.0/perl/rock.pl
当然,脚本的path也应该可以被服务器读取。 在现实世界中,您可能希望获得更严格的权限,但是为了testing的目的,这些工作正在进行中,这就好了。
从我上面的理解,我们只能从一个特定的文件夹,我们把上面的指令运行Perl脚本。 所以再次的问题,我们可以做出这个指令每域的所有域或特定数量的域?
你引用的文件只是一个例子。 您可以启用mod_perlregistry以使用<Location>
甚至<LocationMatch>
指令在任何地方运行Perl脚本。 如果你只想在特定的域上使用它们,把它们放在<VirtualHost>
指令中,而不是在VirtualHost之外。
search后,挖掘,这里是简短和清晰的步骤,每域mod_perl的安装和configuration。
使用cpan从你的shell安装mod_perl:
%cpan cpan> install mod_perl cpan>exit
login到您的WHM,然后:
*)- WHM: Main >> Service Configuration >> Apache Configuration >> Include Editor under Pre Main Include: LoadModule perl_module modules/mod_perl.so then click "Update" *) - Login as root from telnet. *) - % mkdir - p /usr/local/apache/conf/userdata/std/2/username/domain.com *)- cd /usr/local/apache/conf/userdata/std/2/username/domain.com *)- % pico custom.conf *)- put this code in the file custom.conf: Alias /apps/ /home/username/public_html/apps/ <Location /apps/> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI Order allow,deny Allow from all </Location> *)- % /scripts/ensure_vhost_includes --all-users *)- create the folder mkdir -p /home/username/public_html/apps/ *)- put a test script in the /home/username/public_html/apps/ folder *)- call the test script: http://domain.com/apps/test.cgi *)- the output should be: mod_perl 2.0 rocks! MOD_PERL: mod_perl/2.0.7 *)- replace username by the domain username, domain.com with the actual domain name. Also rename the apps folder to anything you want to run mod_perl scripts direct.
testing脚本test.cgi的代码是:
#!/usr/bin/perl print "Content-type: text/plain\n\n"; print "mod_perl 2.0 rocks!\n"; #my $q = $ENV{MOD_PERL} ? CGI->new(shift @_) : CGI->new(); print "MOD_PERL: " . $ENV{MOD_PERL},"\n";
httpd.conf中的cpanel说:
# To customize this VirtualHost use an include file at the following location # Include "/usr/local/apache/conf/userdata/std/2/gamept/domain.com/*.conf"
谢谢大家