我最近使用 slackpkg 更新了我的 Slackware13.37,现在 Firefox 显示我的 perl.cgi 脚本的内容而不是执行。 我正在使用:
bash-4.2# httpd -v
Server version: Apache/2.4.2 (Unix) Server built: May 24 2012 14:55:44
bash-4.2# firefox -v
Mozilla Firefox 12.0
bash-4.2# perl -v
This is perl 5, version 16, subversion 0 (v5.16.0) built for i486-linux-thread-multi
脚本在更新之前有效
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI;
use DBI;
use PDF::API2::Simple;
use PDF::Table;
use Data::Types qw(:all);
my @param=();
###############################
### main ####
###############################
my $q = new CGI;
if(!defined $q->param('login')){
if(!defined $q->param('query')){main::login_relogin('Welcome');
}else{
my ($fname,$lname,$sec,$w,$h) = main::read_cookie();
if(defined $sec){
main::home($fname,$lname,$sec,$w,$h,$q->param('query'),$q->param('param1'),$q->param('param2'));
}else{main::login_relogin('Your session expired !!!');}
}
etc... etc...
请帮忙
最佳答案
我在使用 Apache 2.4.2 时也遇到了同样的问题。
问题已解决:mod_cgi.so 默认情况下不会在我的系统 (openSUSE 12.1) 上构建。当我构建 Apache 2.2 时,CGI 是核心的一部分,而不是像 2.4 中那样是动态模块。所以在运行configure时,需要添加--enable-cgi。另外,在 httpd.conf 中取消注释“LoadModule dir_modulemodules/mod_cgi.so”
或者,使用 mod_cgid.so,它是在我的系统上构建的。每http://httpd.apache.org/docs/current/mod/mod_cgi.html
“在unix下使用多线程MPM时,应该使用模块mod_cgid来代替该模块。在用户级别,这两个模块本质上是相同的”
因此,取消 httpd.conf 中“LoadModule dir_modulemodules/mod_cgid.so”的注释。还要取消 httpd.conf 中“Scriptsock logs/cgisock”的注释(在指令中)。
关于perl - 我的浏览器显示 perl.cgi 脚本的内容而不是执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10835436/