Perl/CGI 不适用于 /home/user/cgi 但适用于 /var/www/cgi-bin
Perl/CGI not working for /home/user/cgi but working for /var/www/cgi-bin
我的服务器是
CentOS7
阿帕奇 2.4
启用 SELinux。
Perl/CGI 适用于 /var/www/cgi-bin 目录,但不适用于 /home/user/cgi 目录。
错误日志显示 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
Link 到 httpd 相关的 sebool 选项:
sebool
非常感谢帮助...
我明白了。
问题是由这一行引起的:
SuexecUserGroup "#1000" "#1000"
删除该指令后问题就解决了。
我的服务器是
CentOS7
阿帕奇 2.4
启用 SELinux。
Perl/CGI 适用于 /var/www/cgi-bin 目录,但不适用于 /home/user/cgi 目录。
错误日志显示 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
Link 到 httpd 相关的 sebool 选项: sebool 非常感谢帮助...
我明白了。
问题是由这一行引起的:
SuexecUserGroup "#1000" "#1000"
删除该指令后问题就解决了。