Ubuntu PHP5 / Apache2 - 显示500错误而不是错误消息

时间:2011-03-10 05:04:50

标签: php http apache2 httpd.conf

以下脚本未向浏览器输出错误消息。相反,它会导致HTTP错误500响应。

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');

phpinfo();

echo "test" asdf // This should error
?>

想法?这是ubuntu上基本的php5 / apache2安装。 httpd.conf是空白的,没有.htaccess文件。

error.log文件显示错误消息:

  

语法错误,意外T_STRING,期待','或';'

这是正确的。

1 个答案:

答案 0 :(得分:3)

<?php
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

phpinfo();

echo "test" asdf // This should error
?>

error_reporting -1中显示的内容甚至超过E_ALLdisplay_errors我使用的值1代替On

http://php.net/manual/en/function.error-reporting.php http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors

编辑:我得到了答案!

  

如果脚本有一个解析错误阻止它运行,这也会阻止它来自&gt;改变PHP设置。

https://serverfault.com/questions/242662/ubuntu-php5-apache2-displaying-500-error-instead-of-error-message

相关问题