gar*_*arh 8 php debian php.ini apache-2.2
我刚刚从 Debian Lenny 升级到 Squeeze 并注意到我的 /var/log/apache2/errors.log 受到以下错误的轰炸:
<b>Warning</b>: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>: Directive 'register_globals' is deprecated in PHP 5.3 and greater in <b>Unknown</b> on line <b>0</b><br />
Run Code Online (Sandbox Code Playgroud)
我觉得这很奇怪,因为这是一个系统日志,而 php(通过 apache)试图将 html 代码写入其中。这似乎发生在服务器(包括任何虚拟主机)上的每个页面加载上。
将这些值设置为 off 目前不是一个选项(我正在运行一个未维护的代码库)。我的 php.ini 包含以下内容:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
display_errors = On
register_globals = On
magic_quotes_gpc = On
Run Code Online (Sandbox Code Playgroud)
我不确定这是 php 配置还是 apache 配置的错误。有谁知道我如何避免在每个页面加载时将这些消息写入 errors.log ?
谢谢,加达尔
Lad*_*ada 10
虽然此处的其他答案将停止将错误写入您的错误日志,但它们只是忽略错误消息而不是修复错误。
在这种情况下的错误是你的 php.ini 仍然有其中之一magic_quotes_gpc on
或magic_quotes_gpc off
某处。对于register_globals on
or也是如此register_globals off
。
错误不是指令是打开还是关闭。错误是该指令根本不应该存在。将这些行从 php.ini 中注释掉或完全删除它们,PHP 将停止编写有关已弃用指令的错误。
当然,如果您的应用程序需要打开其中任何一个,这可能会导致您的应用程序出现问题。
这是 PHP 5.3 中的错误的原因是,在 PHP 6 中,这些指令甚至不存在,PHP 6 的行为就像它们被设置为关闭一样。如果您计划升级到 PHP 6,现在是开始升级或替换应用程序的好时机。
您可以尝试的另一个解决方案是将 PHP 降级回 5.2 或 5.1 分支。
至于 PHP 将错误写入 Apache 的日志,这是很自然的,因为 PHP 作为 Apache 模块运行。您可以将类似的内容error_log = /var/log/php_errors.log
放入 php.ini 并重新启动 Apache,以便将 PHP 错误与 Apache 错误分开。当您在那里时,我建议您更改display_errors
为off
. 错误消息通常可能包含您不希望攻击者看到的敏感信息。您很可能会在 php.ini 中看到以下内容:
; - display_errors = Off [Security]
; With this directive set to off, errors that occur during the execution of
; scripts will no longer be displayed as a part of the script output, and thus,
; will no longer be exposed to remote users. With some errors, the error message
; content may expose information about your script, web server, or database
; server that may be exploitable for hacking. Production sites should have this
; directive set to off.
Run Code Online (Sandbox Code Playgroud)
错误消息包含 HTML 没有合理的理由。
要回答您没有问过的另一个问题,PHP 报告此问题的原因in <b>Unknown</b> on line <b>0</b>
是该错误消息是为您编写的 PHP 代码行而设计的,但它发现的错误是在解析 php.ini 之前它甚至阅读一行代码,甚至打开一个 .php 文件。由于它没有打开文件并且没有行号,所以它会将它们报告为“未知”和“0”。
归档时间: |
|
查看次数: |
18821 次 |
最近记录: |