我试图从浏览器运行一个简单的fcgi程序(用于测试目的)。
我把代码从这里拿走了:(fcgi不是cgi)
Run a C Program on a Linux Server
我在http头的末尾用\n\r\n\r替换了\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
非常感谢。
最佳答案
以下是从原始问题中提取的:
@grebneke结果发现权限实际上是不正确的!
这可能有助于其他人:
确保脚本从命令行运行(谢谢@grebneke!)
我应用了以下命令以正确设置权限:
[根@s1 cgi bin]chmod a+rx file.fcgi
[根@s1 cgi bin]chown yourapacheuser:yourapacheuser file.fcgi
顺便说一下,我从mysite.com/cgi-bin/file.fcgi运行了这个文件。
不确定这是否是必需的,但我的虚拟主机中也有:
AddHandler fcgid-script .fcgi
关于c - C程序(编译为fcgi)给出500内部错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21531263/