php 500内部服务器错误,如何调试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22170864/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
500 internal server error, how to debug
提问by myadmins
I have internal server errors on my POST requests. How can I debug them ? Is it something to set up in php.ini ? THe file is really big and the word 'error' is met there many-many times.
我的 POST 请求出现内部服务器错误。我该如何调试它们?是否需要在 php.ini 中设置?该文件非常大,并且在那里多次遇到“错误”一词。
回答by Philippe Signoret
You can turn on your PHP errors with error_reporting:
您可以使用以下命令打开 PHP 错误error_reporting:
error_reporting(E_ALL);
ini_set('display_errors', 'on');
Edit: It's possible that even after putting this, errors still don't show up. This can be caused if there is a fatal error in the script. From PHP Runtime Configuration:
编辑:有可能即使在放置之后,错误仍然不会出现。如果脚本中存在致命错误,则可能会导致这种情况。从PHP 运行时配置:
Although display_errors may be set at runtime (with ini_set()), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.
尽管可以在运行时设置 display_errors(使用 ini_set()),但如果脚本有致命错误,它不会有任何影响。这是因为未执行所需的运行时操作。
You should set display_errors = 1in your php.inifile and restart the server.
您应该display_errors = 1在您的php.ini文件中进行设置并重新启动服务器。
回答by James Elliott
Try writing all the errors to a file.
尝试将所有错误写入文件。
error_reporting(-1); // reports all errors
ini_set("display_errors", "1"); // shows all errors
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
Something like that.
类似的东西。

