Apache/httpd/var/www/html/.cgi 脚本抛出 500 内部服务器错误 [英] Apache/httpd /var/www/html/ .cgi scripts throw 500 internal server error

查看:21
本文介绍了Apache/httpd/var/www/html/.cgi 脚本抛出 500 内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天安装了一个新的 CentOS 7 x86_64 LAMP 服务器.

I installed a new CentOS 7 x86_64 LAMP server today.

我用 c 编译了一个简单的 CGI 脚本并将其命名为 test.cgi,并为 .cgi 脚本启用了 AddHandler.但是,每次我尝试从/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,而 apache/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.

在灯泡安装后我也没有创建任何额外的用户,所以我现在使用 root 来做所有事情.但是,我尝试修复将/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-script .cgi .pl

And of course I activated CGI using: AddHandler cgi-script .cgi .pl

这是我的简单 test.c 文件:

This is my simple test.c file:

#include <stdio.h>

int main(void) {
  puts("Content-Type: text/html; charset=ISO-8859-1
");
  fputs("Hello, World!", stdout);

  return 0;
}

输出正确:Content-Type: text/html;charset=ISO-8859-1 你好,世界!

The output is correctly: Content-Type: text/html; charset=ISO-8859-1 Hello, World!

我也用 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?

提前致谢,佐加托内

推荐答案

我刚刚解决了重新安装服务器并重新开始,禁用了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 ;)

这篇关于Apache/httpd/var/www/html/.cgi 脚本抛出 500 内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆