【发布时间】: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=在生产环境中打开不是一个好主意,因为它可能会给恶意方提供线索,帮助他们利用您的服务/系统。