PHP 不显示错误 - 内部服务器错误 (500)
我已经在 Amazon AWS 上使用 *Apache2/MySQL/PHP5 全新安装了 Ubuntu Server 12.04 LTS.当我运行 PHP 脚本并遇到错误时,我没有看到来自 PHP 的任何错误报告,我看到的是
I've set up a fresh install of Ubuntu Server 12.04 LTS on Amazon AWS with *Apache2/MySQL/PHP5. When I run a PHP script and it encounters an error I don't see any error reporting from PHP, all I see is
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request.
我已经检查了我的 /etc/php5/apache2/php.ini
文件,据我所知应该设置错误报告.文件内容(关于错误)是:
I have checked my /etc/php5/apache2/php.ini
file and as far as I can tell error reporting should be set up. The contents of the file (regarding errors) are:
; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off
; display_startup_errors
; Default Value: Off
; Development Value: On
; Production Value: Off
; error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
谁能给点建议?如果我尝试诸如 $obj = new ObjectDoesntExist;
之类的东西,它不会告诉我 Fatal error: Class 'ObjectDoesntExist'
它会给我一个服务器 500 错误.
Can anyone advise? If I try something like $obj = new ObjectDoesntExist;
it doesn't tell me Fatal error: Class 'ObjectDoesntExist'
it gives me a server 500 error.
有什么建议吗?
* 我安装的模块是:mysql-server mysql-client apache2 php5 libapache2-mod-php5 phpmyadmin
.除此之外,它是 Ubuntu Server 12.04 LTS 的完全基础安装
* The modules I have installed are: mysql-server mysql-client apache2 php5 libapache2-mod-php5 phpmyadmin
. Other than that it is a completely base install of Ubuntu Server 12.04 LTS
如果我在脚本的开头使用 ini_set('display_errors', '1');
,它会正常显示错误,但如何在整个站点范围内启用?
If I use ini_set('display_errors', '1');
at the start of my script it displays errors as normal, but how do I enable this site wide?
您粘贴的 php.ini 代码段在每一行中都有一个分号(; 字符).分号是 php.ini 中注释的开始,因此分号之后的行中的所有内容都不会使用.尝试手动将 display_errors 设置为 on 并将 error_reporting 设置为 E_ALL,或删除适当的分号来解决此问题.
The php.ini snippet you pasted has a semicolon (the ; character) in each line. The semicolon is the start of a comment in php.ini, so everything in a line following a semicolon is not used. Try manually setting display_errors to on and error_reporting to E_ALL, or removing the appropriate semicolons to fix this.
此外,检查您的 apache 的错误日志,php 可能会在那里记录错误.
Furthermore, check your apache's error log, php might be logging its errors there.