如何让 PHP 显示错误而不是给我 500 Internal Server Error [英] How can I make PHP display the error instead of giving me 500 Internal Server Error

查看:36
本文介绍了如何让 PHP 显示错误而不是给我 500 Internal Server Error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是以前从未发生过的.通常它会显示错误,但现在它只给我一个 500 内部服务器错误.当然之前,当它显示错误时,是不同的服务器.现在我在一台新服务器上(我有完整的 root,所以如果我需要在 php.ini 中的某处配置它,我可以.)或者也许它与 Apache 有什么关系?

This has never happened before. Usually it displays the error, but now it just gives me a 500 internal server error. Of course before, when it displayed the error, it was different servers. Now I'm on a new server (I have full root, so if I need to configure it somewhere in the php.ini, I can.) Or perhaps its something with Apache?

我一直在忍受它,只是将文件传输到我的另一台服务器并在那里运行它以查找错误,但这变得太乏味了.有没有办法解决这个问题?

I've been putting up with it by just transferring the file to my other server and running it there to find the error, but that's become too tedious. Is there a way to fix this?

推荐答案

检查 error_reportingdisplay_errorsdisplay_startup_errors 设置在您的 >php.ini 文件.它们应该分别设置为 E_ALL"On"(虽然你不应该在生产服务器上使用 display_errors,所以禁用它并使用 log_errors 代替,如果/当您部署它时).您还可以在脚本的最开始更改这些设置(display_startup_errors 除外),以便在运行时进行设置(尽管您可能无法通过这种方式捕获所有错误):

Check the error_reporting, display_errors and display_startup_errors settings in your php.ini file. They should be set to E_ALL and "On" respectively (though you should not use display_errors on a production server, so disable this and use log_errors instead if/when you deploy it). You can also change these settings (except display_startup_errors) at the very beginning of your script to set them at runtime (though you may not catch all errors this way):

error_reporting(E_ALL);
ini_set('display_errors', 'On');

之后,重启服务器.

这篇关于如何让 PHP 显示错误而不是给我 500 Internal Server Error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆