Reputation: 59
I'm trying to run a simple fcgi program (for testing purposes) from my browser.
I took the code from here: (fcgi not cgi) Run a C Program on a Linux Server
I replaced \n\n with \n\r\n\r at the end of the HTTP header.
I also made sure http.conf has the following 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>
I added the handler line for fcgi files only, the rest was generated by Virtualmin when creating the sub domain.
I've been searching for the past 2h and made some experiments without any good results. I always get 500 Internal Server Error.
Error log:
[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
Thank you very much.
Upvotes: 2
Views: 289
Reputation: 11571
The following is extracted from the original question:
@grebneke it turned out that permissions were actually incorrect!
This may help other people:
Make sure the script runs from the command line (thanks @grebneke !)
I applied the following commands to set the permissions properly:
[root@s1 cgi-bin]# chmod a+rx file.fcgi
[root@s1 cgi-bin]# chown yourapacheuser:yourapacheuser file.fcgi
I ran the file from mysite.com/cgi-bin/file.fcgi by the way. Not sure if this mandatory but I also have this in my virtual host:
AddHandler fcgid-script .fcgi
Upvotes: 1