【问题标题】:Perl/CGI not working for /home/user/cgi but working for /var/www/cgi-binPerl/CGI 不适用于 /home/user/cgi 但适用于 /var/www/cgi-bin
【发布时间】:2016-04-13 19:41:17
【问题描述】:

我的服务器是
CentOS7
阿帕奇 2.4
启用 SELinux。

Perl/CGI 适用于 /var/www/cgi-bin 目录,但不适用于 /home/user/cgi 目录。

error-log 显示 test.pl 的以下错误:

[Fri Jan 08 19:53:05.725795 2016] [cgi:error] [pid 7311] [client *:33769] 头文件前的脚本输出结束:test.pl
[Fri Jan 08 19:54:10.981964 2016] [cgi:error] [pid 7314] [client *:33770] 头文件前的脚本输出结束:test.pl

perl -w test.pl 在命令行上没有显示错误。

/home/user/cgi 目录的 SELinux 设置是

drwxr-xr-x。 4 unconfined_u:object_r:httpd_sys_script_exec_t:s0 用户用户 83 Jan 8 20:05 。
drwxr-xr-x。 11 unconfined_u:object_r:user_home_dir_t:s0 用户用户 4096 Jan 7 12:08 ..
-rwxr-xr-x。 1 unconfined_u:object_r:httpd_sys_script_exec_t:s0 user user 90 Jan 8 20:05 test.pl

test.pl 的内容

#!/usr/bin/perl

print "内容类型: text/html; charset=utf-8\n\n";
打印“你好\n\n”;

httpd.conf

选项索引 FollowSymLinks 包括 ExecCGI AddHandler cgi-script .cgi .pl 要求所有授予 DirectoryIndex index.pl index.cgi

链接到 httpd 相关的 sebool 选项: sebool 非常感谢帮助...

【问题讨论】:

  • Apache 错误日志中有内容吗? (可能类似于/var/log/apache2/error.log)。
  • 我在 /var/log/httpd/error_log 中没有看到与此错误相关的任何内容。不过,这里是日志内容的链接。也许我错过了什么! : [链接] (business-impact-solutions.com/error_log_2016-08-01.txt)
  • 也许是旧的文件缓冲?尝试把 $|=1;在脚本中的任何打印语句之前。
  • 不,$|=1; 没有解决问题
  • 我假设您显示的 httpd.conf 部分位于 <Directory> 块内。哪个目录? (您需要显示 /var/www/cgi-bin 和 /home/user/cgi 的配置,我们才能提供帮助。)

标签: perl cgi centos7 apache2.4 selinux


【解决方案1】:

我明白了。

问题是由这一行引起的:

SuexecUserGroup "#1000" "#1000"

删除该指令后问题解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-09
    • 2012-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-04
    • 1970-01-01
    相关资源
    最近更新 更多