I'm trying to run an Apache server that executes some scripts over fast CGI, but I can't figure out for the life of me how to actually get it to work. My problem in particular is the "Error 500: End of script output before headers".
I've been reading a lot about this, following every suggestion I can find but still no luck. There were some about IOTimeout and BusyTimeout and every other kind of Fcgid timeout available, but those did nothing and I don't think my problem is related to it.
Starting from a fresh linux installation this is what I've done:
Created a new empty web at
/var/www/testwith some empty files and a script. I've set the permissions accordingly and just to be sure changed the owner and group to http.
$ ls -l /var/www drwxrwxr-x 1 http http 122 Nov 8 16:08 test/ $ ls -l /var/www/test -rw-rw-r-- 1 http http 0 Nov 8 15:29 file01.txt -rw-rw-r-- 1 http http 0 Nov 8 15:29 file02.txt -rw-rw-r-- 1 http http 0 Nov 8 15:29 file03.txt -rwxr-xr-x 1 http http 107 Nov 8 16:08 run.fcgi* $ cat /var/www/test/run.fcgi #!/usr/bin/perl use strict; use warnings; print "Content-type: text/html\n\n"; print "Hello world.\n";
I've appended this to
LoadModule fcgid_module modules/mod_fcgid.so <IfModule fcgid_module> AddHandler fcgid-script .fcgi </IfModule> <VirtualHost *:80> DocumentRoot /var/www/test <Directory /var/www/test> Options +Indexes +ExecCGI Require all granted </Directory> </VirtualHost>
Now, I can run the script perfectly fine from the terminal. When I then head over to
http://localhost I get a list of the directory files as expected, but when I then open the script I get the error 500 mentioned above. The apache's error log shows this (snipped unnecessary parts):
Content-type: text/html Hello world. (...) Connection reset by peer (...) mod_fcgid: error reading data from FastCGI server, referer: (...) (...) End of script output before headers: run.fcgi, referer: (...)
Why is it that the script's output got logged into the error log? I think this is related to permissions and ownership, but I can't figure out how, I think I've set all of them accordingly. Do you have any idea what I can do to get this to run?
I'm trying to run all this in a 64-bit Arch linux box.
Thank you all!