Can't get Perl FastCGI script to run on Apache Server: Error 500
2
votes
2
answers
3117
views
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:
1. Installed
apache
and mod_fcgid
.
2. Created a new empty web at /var/www/test
with 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";
3. I've appended this to /etc/httpd/conf/httpd.conf
:
LoadModule fcgid_module modules/mod_fcgid.so
AddHandler fcgid-script .fcgi
DocumentRoot /var/www/test
Options +Indexes +ExecCGI
Require all granted
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!
Asked by elpato
(145 rep)
Nov 8, 2015, 07:48 PM
Last activity: Feb 19, 2020, 05:13 AM
Last activity: Feb 19, 2020, 05:13 AM