I have python CGI script that runs perfect on my local Apache 2.2.22 server. It outputs correct result and so on. But when I try to execute it on virtual hosting, there is error 500. I really have no idea why it does not works.
Apache error log looks like:
[Wed Jul 12 16:06:54 2013] [error] [client 89.223.235.12] Premature end of script headers: /home/u67442/rrrrr.com/cgi-bin/test.py
[Wed Jul 12 16:09:31 2013] [error] [client 89.223.235.12] Premature end of script headers: /home/u67442/rrrrr.com/cgi-bin/test.py
I've already tried following things:
- I'm sure that path to interpreter is correct -
#!/usr/local/bin/python
. Another CGI script works fine with this path. - I have set chmod 755 to this script.
- I have set end-of-line characters in UNIX-format.
- I use correct HTTP-header:
print "Content-type:text/html\n\n"
Output section of script:
print "Content-type:text/html\n\n"
print "<html>"
print "<head>"
print "<title>Results</title>"
print "<head><h2 align=center>Results</h2></head>"
print "</head>"
print '<body bgcolor="#e8f3d8">'
print "<hr>"
print "<b>Result = %s </b>" % str(round(total_sum, 5))
print "</body>"
print "</html>"
Funny that another VERY similar script with the same path, header, EOL, output and so on works perfect on local server and virtual hosting. And it's very strange that this script works fine on my local apache, but on virtual web hosting it crashes with 500 internal server error. I really don't know what to do. In technical support says that there is problem in my script.
There is only one idea - timeout of waiting of output. Data processing in my script takes about 15-25 seconds.
What can you advice?