How to get more information about error 500 - internal server error?

前端 未结 7 2148
粉色の甜心
粉色の甜心 2021-01-05 23:00

I use $ajax requests in many parts of my PHP website everything was working perfectly until few days ago all my $ajax requests start giving e

7条回答
  •  醉梦人生
    2021-01-05 23:32

    Well, the "Premature end of script headers" is pretty common, and there's few possibilities. It indicate that PHP script has been stopped for some reason before sending any output. It's nothing to do with AJAX itself.

    Possibilities:

    1. Apache misconfiguration

    Upgrading or downgrading to a different version of PHP can leave residual options in the httpd.conf. Check the current version of PHP using php -v on the command line and search for any lines mentioning another version in the httpd.conf. If you find them, comment them out, distill the httpd.conf and restart apache.

    Check your Apache configuration for any changes and revise PHP's module list (try to disable them one by one).

    2. Resource limit

    The RLimitCPU and RLimitMEM directives in the httpd.conf may also be responsible for the error if a script was killed due to a resource limit.

    3. Third party extension

    A configuration problem in suEXEC, mod_perl, or another third party module can often interfere with the execution of scripts and cause the error. If these are the cause, additional information relating to specifics will be found in the apache error_log.

    4. SuPHP crashing

    If suphp’s log reaches 2GB in size or larger you may see the premature end of scripts headers error. See what the log contains and either gzip it or null it. Restart apache and then deal with any issues that the suphp log brought to light. The suphp log is located at: /usr/local/apache/logs/suphp_log

    5. File permissions

    The script’s permissions may also cause this error. CGI scripts can only access resources allowed for the User and Group specified in the httpd.conf. In this case, the error may simply be pointing out that an unauthorized user is attempting to access a script.

    As you can see, there's few possibilities. You mentioned that it crashes only sometimes, so it may be something with resources or configuration. For example - if your server is under heavy load, Apache can reject your request and throw this generic "Premature end of script headers" error.

    What have you tried already?

提交回复
热议问题