Error 500: Premature end of script headers

前端 未结 15 1376
臣服心动
臣服心动 2020-12-01 14:31

I get a \"Premature end of script headers: contactform.cgi\" error message when running the below script. What frustrates me is that I ran this as a .php on another server

相关标签:
15条回答
  • 2020-12-01 14:46

    After many diff's, this was what was missing from the httpd.conf file on the server in question:

    AddHandler php5-script .php
    

    Solved the issue.

    0 讨论(0)
  • 2020-12-01 14:48

    I tried all of the above but found out it was a missing windows compiler.

    Downloading and installing this fixed the issue. To see if this is your problem, try to run PHP from command line.

    msvcr110.dll is missing from computer error while installing PHP

    0 讨论(0)
  • 2020-12-01 14:52

    Check your line endings! If you see an error about the file not being found, followed by this "premature of end headers" error in your Apache log - it may be that you have Windows line endings in your script in instead of Unix style. I ran into that problem / solution.

    0 讨论(0)
  • 2020-12-01 14:52

    I bumped into this problem using PHP-FPM and Apache after increasing Apache's default LimitRequestFieldSize and LimitRequestLine values.

    The only reason I did this (apache says don't mess) is because Yii2 has some pjax problems with POST requests. As a workaround, I decided to increase these limits and use gigantic GET headers.

    php-fpm barfed up the 500 error though.

    0 讨论(0)
  • 2020-12-01 14:54

    In my case it was a cache directory that wasn't so big, only 17MB but duo to the file structure it took forever to be accessed by the website and was producing that error after max_execution_time was reached.

    I renamed the directory to cache-BK and created a new cache directory with the same permissions and that solved the problem.

    0 讨论(0)
  • 2020-12-01 14:56

    The "Premature end of script headers" error message is probably the most loathed and common error message you'll find. What the error actually means, is that the script stopped for whatever reason before it returned any output to the web server. A common cause of this for script writers is to fail to set a content type before printing output code. In Perl for example, before printing any HTML it is necessary to tell the Perl script to set the content type to text/html, this is done by sending a header, like so:

    print "Content-type: text/html\n\n";
    

    (source; http://htmlfixit.com/cgi-tutes/tutorial_Common_Web_dev_error_messages_and_what_they_mean.php#premature

    0 讨论(0)
提交回复
热议问题