Perl / CGI不适用于/ home / user / cgi但是为/ var / www / cgi-bin

时间:2016-01-09 01:16:46

标签: perl cgi centos7 apache2.4 selinux

我的服务器是
    CentOS7
    Apache 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] End of script output before headers: test.pl
[Fri Jan 08 19:54:10.981964 2016] [cgi:error] [pid 7314] [client *:33770] End of script output before headers: test.pl

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

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

drwxr-xr-x.  4 unconfined_u:object_r:httpd_sys_script_exec_t:s0 user user   83 Jan  8 20:05 .
drwxr-xr-x. 11 unconfined_u:object_r:user_home_dir_t:s0 user user 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 "Content-type: text/html; charset=utf-8\n\n";
print "Hello\n\n";

的httpd.conf

Options Indexes FollowSymLinks Includes ExecCGI
AddHandler cgi-script .cgi .pl
Require all granted
DirectoryIndex index.pl index.cgi 

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

1 个答案:

答案 0 :(得分:0)

我明白了。

问题是由这一行引起的:

SuexecUserGroup "#1000" "#1000"

删除该指令后问题已解决。