【问题标题】:is it ok to have php.ini display_errors=On production environmentphp.ini display_errors=On生产环境可以吗
【发布时间】:2015-10-15 07:14:59
【问题描述】:

生产环境

我有 check.php

<?php
test();
?>

做的时候

curl -v http://xxx.xxx.xxx.xxx/test.php

如果我的生产环境中的php.ini有

display_errors=Off

我得到下面的标题

* HTTP 1.0, assume close after body
HTTP/1.0 500 Internal Server Error
Date: Fri, 24 Jul 2015 08:10:41 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.29
Content-Length: 0
Connection: close
Content-Type: text/html; charset=UTF-8

* Closing connection #0

如果我把它改成

display_errors=On

我得到下面的标题

HTTP/1.1 200 OK
Date: Fri, 24 Jul 2015 08:13:04 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.29
Content-Length: 119
Connection: close
Content-Type: text/html; charset=UTF-8

<br />
<b>Fatal error</b>:  Call to undefined function test() in <b>/var/www/html/check.php</b> on line <b>2</b><br />
* Closing connection #0

所以,当我有

display_errors=Off

我明白了

500 Internal Server Error

所以,为了避免 500 Internal Server Error,我需要 display_errors=On

可以吗

display_errors=On

在生产环境上?

【问题讨论】:

  • 我很困惑,为什么要让生产服务器显示“调用未定义函数...”?您确定要在开发中解决此问题吗? display_errors=在生产环境中打开不是一个好主意,因为它可能会给恶意方提供线索,帮助他们利用您的服务/系统。

标签: php php-ini


【解决方案1】:

500 Internal Server Error 有什么问题?!这正是你所经历的。你的剧本错了,猝死;这是您服务器的内部错误。 500 响应向客户端发出信号,表明存在不是客户端错误的错误,因此客户端不应使用它收到的任何响应,并且可能稍后再试。这正是在这种情况下必须发生的事情,这就是 display_errors=off 所做的事情。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-16
    • 2013-02-28
    相关资源
    最近更新 更多