PHP 错误未显示在浏览器中 [Ubuntu 10.10]
我对 PHP 和整个 LAMP 堆栈很陌生,但我已经设法在我的 Ubuntu 10.10 系统上启动并运行它。除了在浏览器中重新发布错误之外,一切似乎都正常工作,我似乎无法正常工作(没有它我就无法工作!)。
我读过许多文章和其他线程,它们表明应在文件 /etc/php5/apache2/php.ini
中应用以下值:
display_errors = On
display_startup_errors = On
我已经重新启动了 apache2,甚至重新启动了我的计算机,但我就是无法让它工作。我什至尝试过使用 phpinfo() 函数,该函数报告这些设置与我设置的一样,所以我知道它正在选择正确的配置文件,但什么也没有!
欢迎任何帮助。
I'm new to PHP and the whole LAMP stack but I've managed to get it up and running on my Ubuntu 10.10 system. Everything seems to be working with the exception of error reposting in the browser which I just can't seem to get working (and which I can't work without!).
I've read a number of article and other threads which indicate that the following values should be applied in the file /etc/php5/apache2/php.ini
:
display_errors = On
display_startup_errors = On
I've restarted apache2 and even restarted my computer but for the life of me I just can't get it working. I've even tried using phpinfo()
function which reports that these settings are as I've set them so I know it's picking up the correct configuration file but nothing!
Any help would be welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
不要只在 php.ini 文件中启用第一次出现的
display_errors
。确保向下滚动到“真实”设置并将其从Off
更改为On
。问题是,如果您在第一次出现
display_errors
时进行更改(即取消注释 + 添加= On
),您的更改将被覆盖在第 480 行设置的某个位置再次关闭
。Don't just enable the first occurrence of
display_errors
in the php.ini file. Make sure you scroll down to the "real" setting and change it fromOff
toOn
.The thing is that if you settle with changing (i.e. uncomment + add
= On
) by the very first occurrence ofdisplay_errors
your changes will be overwritten somewhere on line 480 where it's set toOff
again.我遇到了同样的问题 - 通过在两个
php.ini
文件中设置display_errors = On
解决了这个问题。然后重新启动 Apache:
希望这会有所帮助。
I had the same problem - solved it by setting
display_errors = On
in bothphp.ini
files.Then restarting Apache:
Hope this helps.
为了使其工作,您应该在 php.ini 中更改以下变量:
搜索它们,因为它们已经定义并输入您想要的值。
然后重新启动 apache2 服务器,一切都会正常工作。祝你好运!
To make it work you should change the following variables in your php.ini:
Search for them as they are already defined and put your desired value.
Then restart your apache2 server and everything will work fine. Good luck!
编辑 /etc/php5/apache2/php.ini 后,请务必重新启动 apache。
您可以通过运行以下命令来执行此操作:
After you edit /etc/php5/apache2/php.ini be sure to restart apache.
You can do so by running:
display_errors = On
/etc/init.d/apache2 restart
display_errors = On
/etc/init.d/apache2 restart
如果您的本地值覆盖主值,则不会更改 php.ini 中的值
查看 .htaccess 或虚拟主机配置文件中的这些变量。
如果编辑 vhost,请重新启动 apache,
$ sudo service apache2 restart
.htaccess 编辑不需要重新启动 apache
If you have Local Values overriding master values, you won't change its values in php.ini
take a look for those variables in a .htaccess or in the virtual-host config file.
If you edit vhost, restart apache,
$ sudo service apache2 restart
.htaccess edits don't need apache to restart
请按照以下步骤操作,
Follow the below steps,
使用
phpinfo();
函数查看浏览器上的设置表并查找并编辑该文件。您的计算机可以有多个 php.ini 文件,您需要编辑正确的文件。
另请检查该文件内的
display_errors = On
、html_errors = On
和error_reporting = E_ALL
重新启动 Apache。
Use the
phpinfo();
function to see the table of settings on your browser and look for theand edit that file. Your computer can have multiple php.ini files, you want to edit the right one.
Also check
display_errors = On
,html_errors = On
anderror_reporting = E_ALL
inside that fileRestart Apache.
这里有很多关于如何查找和修改
php.ini
文件的答案,一般来说,这是最好的方法:在服务器配置中设置正确的设置。但在某些情况下,使用共享主机时,您可能无法修改您的
php.ini
文件,或者您可能需要提交支持请求才能修改它,而您只是没有此权限时间为.如果您突然需要立即打开出错的 PHP 脚本中的错误,而无需查找、修改配置并重新启动服务器,那么请尝试以下操作:
上面发生的情况似乎很清楚,但如果您想了解更多信息:
There are plenty of answers here on how to locate and modify your
php.ini
file, and generally, that is the best approach: set the correct settings in the server configuration.But in some cases, when using shared hosting, you might not be able to modify your
php.ini
file, or, you may need to submit a support request to modify it, which you just do not have time for.If you suddenly and immediately need to turn on errors in your erroring PHP script, without having to hunt down, modify the configs, and restart your server, then try this:
It seems clear what's happening above, but if you want to learn more:
查看 php.ini 中的 error_reporting 指令。
Look at error_reporting directive in php.ini.
当我意识到我正在使用开放短标记形式时,我只是陷入了同样的问题:
您必须转到
/etc/apache2/php.ini
文件并设置 < code>short_open_tag = Off 改为On
,然后sudo service apache2 restart
!干杯!
I was just stuck on the same issue, when I've realized that I was using the open short tag form:
You have to go to your
/etc/apache2/php.ini
file and set theshort_open_tag = Off
toOn
, thensudo service apache2 restart
!Cheers!
它应该重叠,所以它被关闭。尝试在文本编辑器中打开并找到
display_errors
并将其打开。这对我有用it's should overlap, so it turned off. Try to open in your text editor and find
display_errors
and turn it on. It works for me尝试添加 log_errors = Off 并检查 error_reporting 设置是否设置得足够高。
Try adding log_errors = Off and check the error_reporting setting whether it's set high enough.