Weird 500 Internal Server Error (firebug, php, display_errors, ajax)

╄→尐↘猪︶ㄣ 提交于 2019-12-06 06:08:02

The most likely answer, given the limited information available, is that PHP is reaching a fatal error after it has finished echoing your expected output.

To test: in the line that gets executed last, echo something. If that echo doesn't show up, then you know that your PHP script is halting somewhere. At that point, it's just a matter of debugging and tracing.

That's very strange... Are you using some kind of library or other code that you didn't write that might be affecting the status code header independently of the actual returned value?

I had this exact same issue, turned out to be a hidden Fatal Error. Turn on display_errors, find error, smash error, turn off display_errors (probably best to keep display_errors on for development and off in production).

The PHP interpreter simply crashes during this one request. I know one potential reason that could crash PHP:

Due to some bugs in GCC 4.3, PHP compiled with this version of compiler has the implementation of exceptions broken. In some non-trivial cases, throwing an exception by the script causes the segfault and the script execution is terminated. The thesis was confirmed by PHP team a couple of months ago.

To verify, whether it happens to you, you can simply check, where the script execution crashes and if happens just after throwing an exception, you're at home. The check can be done by placing die() further and futher in the script and see, what happens. Another way is to use declare(ticks=1) and register a tick function that saves the last entry from debug_backtrace() to the file every tick, so that you'll get a report, how the script is executed.

I've had somewhat similar problem and the issue was that the script was throwing exceptions and there was no catch block so the exception would be bubbled to the surface and fatal error "uncaught exception" happened. Which is standard php behaviour but on one particular server you would also get response code of 500 internal server error instead of 200 OK. Removing exceptions and replacing them with die() statements fixed the problem on that server (we could do that because it was simple script that really didn't benefit from exceptions in the first place)

The problem is often fixed by ione of the following. Check the scripts permissions, rights and ownership. If returned after an ajax call, check whether there is nowhere a fatal error. Check whether you didn;t accidentally uplaoded the file to Unix in ASCII mode.

More info can be read at http://www.larshemel.com/forum/500_internal_server_error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!