阿帕奇/的httpd的/ var / www / html等/的CGI脚本抛出500内部服务器错误 [英] Apache/httpd /var/www/html/ .cgi scripts throw 500 internal server error
问题描述
今天我安装了一个新的CentOS 7 x86_64的LAMP服务器。
I installed a new CentOS 7 x86_64 LAMP server today.
我C编译的一个简单的CGI脚本,我把它称为test.cgi,我启用的AddHandler为的CGI脚本。但是每次我试图从我的/ var / www / html等目录加载页面/test.cgi任何简单的CGI脚本将引发我一个500内部服务器错误页面。
I compiled a simple CGI script in c and i called it test.cgi, and I enabled the AddHandler for .cgi scripts. However everytime i try to load the /test.cgi page from my /var/www/html directory any simple .cgi script will throw me a 500 internal server error page.
我测试的脚本工作从在/ var / WWW / cgi-bin目录的罚款。
我的服务器正在运行SELinux和阿帕奇/ httpd的使用suEXEC的。
I tested that the script is working fine from the /var/www/cgi-bin directory. My server is running selinux and apache/httpd is using suEXEC.
编辑:我也没有创造我用根现在做的一切灯安装所以这里后的任何额外的用户。不过,我试图修复给人的/ var / www / html等目录所有权给Apache用户,这并不可悲的修复。
also I didn't create any extra users after the lamp installation so here I'm using root to do everything for now. However I tried to fix giving the /var/www/html directory ownership to the apache user, that didn't fix sadly.
下面是错误日志,你可以看到它给了我一个权限被拒绝的错误:
Here's the error log, as you can see it gives me a 'Permission Denied' error:
[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] AH01232: 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的配置:
This is my /var/www/html apache config:
<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脚本的CGI特等
这是我简单的test.c的文件:
This is my simple test.c file:
#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的;字符集= ISO-8859-1 \\ n \\ nHello,世界!
此外,我用gcc编译它,然后把它的权限777 test.cgi
你知道我需要做来解决这个问题?
Also i compiled it with gcc and then gave it permissions 777 to test.cgi Do you know what I need to do to fix this?
在此先感谢,
Zorgatone
Thanks in advance, Zorgatone
推荐答案
我刚刚解决重新安装服务器,并做一遍所有,禁用SELinux和iptables的,因为我已经有一个外部防火墙。
I just solved reinstalling the server and doing all over again, disabled selinux and iptables, because I have already an external firewall.
由于任何人谁帮我出;)
Thanks to anyone who helped me out ;)
这篇关于阿帕奇/的httpd的/ var / www / html等/的CGI脚本抛出500内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!