C程序(编译为fcgi)给出500内部错误

时间:2014-02-03 15:31:19

标签: c linux fastcgi webmin

我正在尝试从浏览器运行一个简单的fcgi程序(用于测试目的)。

我从这里拿了代码:(fcgi not cgi) Run a C Program on a Linux Server

我用HTTP标头末尾的\ n \ r \ n \ r \ n替换了\ n \ n。

我还确保http.conf具有以下VirtualHost:

<VirtualHost [snip]>
SuexecUserGroup "#502" "#502"
ServerName [snip]
ServerAlias [snip]
ServerAlias [snip]
ServerAlias [snip]
DocumentRoot /[snip]/public_html
ErrorLog /var/log/virtualmin/[snip].com_error_log
CustomLog /var/log/virtualmin/[snip].com_access_log combined
ScriptAlias /cgi-bin/ /[snip]/[snip].com/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /[snip]/[snip].com/public_html>
    Options -Indexes +IncludesNOEXEC +SymLinksifOwnerMatch +ExecCGI
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    AddHandler fcgid-script .php
    AddHandler fcgid-script .php5
    AddHandler fcgid-script .fcgi
    FCGIWrapper /[snip]/fcgi-bin/php5.fcgi .php
    FCGIWrapper /[snip]/fcgi-bin/php5.fcgi .php5
</Directory>
<Directory /[snip]/cgi-bin>
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.[snip].com
RewriteRule ^(.*) https://[snip]:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.[snip]
RewriteRule ^(.*) http://[snip]:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
php_admin_value engine Off
IPCCommTimeout 31
FcgidMaxRequestLen 1073741824
</VirtualHost>

我只添加了fcgi文件的处理程序行,其余部分是在创建子域时由Virtualmin生成的。

过去2小时我一直在寻找并做了一些没有任何好结果的实验​​。我总是得到500内部服务器错误。

错误日志:

[Mon Feb 03 18:16:39 2014] [warn] [client SNIP] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Mon Feb 03 18:16:39 2014] [error] [client SNIP] Premature end of script headers: pibell_server.fcgi

非常感谢。

1 个答案:

答案 0 :(得分:1)

以下内容摘自原始问题:

@grebneke结果证明权限实际上是不正确的!

这可能有助于其他人:

  1. 确保脚本从命令行运行(感谢@grebneke!)

  2. 我应用以下命令正确设置权限:

    [root @ s1 cgi-bin] #chmod a + rx file.fcgi

    [root @ s1 cgi-bin] #chown yourapacheuser:yourapacheuser file.fcgi

  3. 我顺便从mysite.com/cgi-bin/file.fcgi运行了该文件。 不确定这是否必须,但我也在我的虚拟主机中有这个:

    AddHandler fcgid-script .fcgi