我今天安装了一个新的CentOS 7 x86_64 LAMP服务器。Apache/httpd/var/www/html/.cgi脚本丢500内部服务器错误
我在c中编译了一个简单的CGI脚本,我将其命名为test.cgi,并且为.cgi脚本启用了AddHandler。然而,每次我尝试从/ var/www/html目录加载/test.cgi页面时,任何简单的.cgi脚本都会给我一个500内部服务器错误页面。
我测试了脚本在/ var/www/cgi-bin目录下工作正常。 我的服务器正在运行selinux,而apache/httpd正在使用suEXEC。
编辑:也没有创建任何额外的用户灯安装后,所以在这里我使用root来做所有的事情。不过,我试图解决给Apache的用户/ var/www/html目录所有权,这并没有修复悲伤。
这里的错误日志,你可以看到它给了我一个 '权限被拒绝' 的错误:
[Mon Jul 21 15:28:14.336626 2014] [core:notice] [pid 22704] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Mon Jul 21 15:28:14.339766 2014] [suexec:notice] [pid 22704] AH: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Jul 21 15:28:14.495631 2014] [auth_digest:notice] [pid 22704] AH01757: generating secret for digest authentication ...
[Mon Jul 21 15:28:14.498690 2014] [lbmethod_heartbeat:notice] [pid 22704] AH02282: No slotmem from mod_heartmonitor
[Mon Jul 21 15:28:14.765072 2014] [mpm_prefork:notice] [pid 22704] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16 configured -- resuming normal operations
[Mon Jul 21 15:28:14.765186 2014] [core:notice] [pid 22704] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Jul 21 15:28:16.027553 2014] [cgi:error] [pid 22706] [client 192.168.0.68:52930] AH01215: (13)Permission denied: exec of '/var/www/html/index.cgi' failed
[Mon Jul 21 15:28:16.030595 2014] [cgi:error] [pid 22706] [client 192.168.0.68:52930] End of script output before headers: index.cgi
[Mon Jul 21 15:45:01.586229 2014] [mpm_prefork:notice] [pid 22704] AH00170: caught SIGWINCH, shutting down gracefully
这是我的/ var/www/html等Apache的配置:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options ExecCGI FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
而且我当然激活CGI使用:AddHandler cgi-script .cgi .pl
这是我简单test1.c文件:
#include <stdio.h>
int main(void) {
puts("Content-Type: text/html; charset=ISO-8859-1\n");
fputs("Hello, World!", stdout);
return 0;
}
输出是正确:Content-Type: text/html; charset=ISO-8859-1\n\nHello, World!
而且我用gcc编译它,然后把它的权限777 test.cgi 你知道什么,我需要做的解决这一问题?
由于提前, Zorgatone
我与Centos 7上的CGI脚本有同样的问题。我正在尝试安装Bugzilla。我已经尝试了所有不同的权限,包括删除写入权限并将所有者切换到apache.apache,但都没有效果。 –
500错误非常普遍...检查日志 – user83039