Apache Cgi in User Directory "End of Script Output Before Headers"

Apache CGI in user directory End of script output before headers

Finally I solved that. Thanks to @JimB, because in his comment he pointed out SUEXEC, which I didn't know about (or simply ignored till now).

After reading a bit the suEXEC documentation, I understood the the problem had to be there. So, I took a look at the configuration:

# suexec -V
-D AP_DOC_ROOT="/var/www"
-D AP_GID_MIN=1000
-D AP_HTTPD_USER="apache"
-D AP_LOG_SYSLOG
-D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
-D AP_UID_MIN=1000
-D AP_USERDIR_SUFFIX="public_html"

and everything looked Ok (good uid/gid for my user, userdir_suffix is fine, etc). So I took a look at the system logs:

# journalctl -b | grep "suexec"
May 22 11:43:12 caladan suexec[5397]: uid: (1000/user) gid: (1000/user) cmd: test.cgi
May 22 11:43:12 caladan suexec[5397]: directory is writable by others: (/home/user/public_html/cgi-bin)

and that's the problem: my cgi-bin directory was writable by others.

I fixed by simply changing the permissions to 755.

End of script output before headers when using Anaconda Python in Apache

The problem was due to the line ending difference in Windows and Linux. The file was in CRLF ending and it should change to LF line ending. My text editor Pycharm has a way of changing it at the bottom right corner or in the File menu as shown below. So chaning it to Unix and OS X line separator fixed the issue.

Sample Image

For more from Pycharm check this link.

If you use git, this is automatically fixed when you commit the repository.

Edit:
I recently found out that making the python file executable is needed. Even if I fixed the line ending, I had a problem and making the file executable by checking the checkbox in file permissions fixed the issue.

Sample Image

End of script output before headers in Apache + PHP

The issue was that the request was timing out before the script completed, due to a long-running database query.

So that generic End of script output before headers error can be caused by server timeouts as well as file permissions issues.

End of script output before headers when trying to open file on Apache [Cloud9IDE]

As it turns out, fopen cannot accept URLs. I tried editing the code to:

pfile = fopen("../../../home/ubuntu/workspace/files/html/output.html", "w");

and it worked.

End of script output before headers - CGI on Apache

I don't know why you are using $CGI instead of CGI

I think It should be

my $query = CGI->new;

tested on Linux working perfect.



Related Topics



Leave a reply



Submit