PHP 错误未显示在浏览器中 [Ubuntu 10.10]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5050426/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP errors NOT being displayed in the browser [Ubuntu 10.10]
提问by JLove
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!).
我是 PHP 和整个 LAMP 堆栈的新手,但我已经设法在我的 Ubuntu 10.10 系统上启动并运行它。除了在浏览器中重新发布错误之外,一切似乎都在工作,我似乎无法正常工作(没有它我就无法工作!)。
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
:
我已经阅读了许多文章和其他线程,它们表明应该在文件中应用以下值/etc/php5/apache2/php.ini
:
display_errors = On
display_startup_errors = On
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!
我已经重新启动了 apache2,甚至重新启动了我的计算机,但在我的一生中,我无法让它工作。我什至尝试使用phpinfo()
功能报告这些设置与我设置的一样,所以我知道它正在选择正确的配置文件,但什么也没有!
Any help would be welcome.
欢迎任何帮助。
回答by dbm
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 from Off
to On
.
不要只启用display_errors
php.ini 文件中第一次出现的。确保向下滚动到“真实”设置并将其从 更改Off
为On
。
The thing is that if you settle with changing (i.e. uncomment + add = On
) by the very first occurrence of display_errors
your changes will be overwritten somewhere on line 480 where it's set to Off
again.
问题是,如果您= On
在第一次发生display_errors
更改时解决更改(即取消注释 + 添加),您的更改将在第 480 行的某处Off
再次被覆盖。
回答by Alex
I had the same problem - solved it by setting display_errors = On
in both php.ini
files.
我遇到了同样的问题 - 通过display_errors = On
在两个php.ini
文件中进行设置来解决它。
/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini
Then restarting Apache:
然后重启Apache:
sudo /etc/init.d/apache2 restart
Hope this helps.
希望这可以帮助。
回答by sticksu
To make it work you should change the following variables in your php.ini:
要使其工作,您应该更改 php.ini 中的以下变量:
; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off
; display_startup_errors
; Default Value: On
; 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
; html_errors
; Default Value: On
; Development Value: On
; Production value: Off
; log_errors
; Default Value: On
; Development Value: On
; Production Value: On
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!
搜索它们,因为它们已经定义并输入您想要的值。然后重新启动您的 apache2 服务器,一切都会正常进行。祝你好运!
回答by ChrisC
After you edit /etc/php5/apache2/php.ini be sure to restart apache.
编辑 /etc/php5/apache2/php.ini 后,请务必重新启动 apache。
You can do so by running:
您可以通过运行:
sudo service apache2 restart
回答by Cyborg
- First you need to find the path to the php.inifile
- You will find the file in the specified path /etc/php/7.0/apache2/. If you are changing the values in the CLI folder or the CGI folder it will not work.
- Make the following changes
- 首先你需要找到php.ini文件的路径
- 您将在指定路径/etc/php/7.0/apache2/ 中找到该文件。如果您正在更改 CLI 文件夹或 CGI 文件夹中的值,它将不起作用。
- 进行以下更改
display_errors = On
display_errors = 开
- Restart you apache server
- 重启你的apache服务器
/etc/init.d/apache2 restart
/etc/init.d/apache2重启
回答by juanmf
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.
如果您有覆盖主值的本地值,则不会在 php.ini 中更改其值,请查看 .htaccess 或虚拟主机配置文件中的这些变量。
...
php_admin_value display_errors On
php_admin_value error_reporting E_ALL
</VirtualHost>
If you edit vhost, restart apache,
如果您编辑 vhost,请重新启动 apache,
$ sudo service apache2 restart
$ sudo service apache2 restart
.htaccess edits don't need apache to restart
.htaccess 编辑不需要 apache 重新启动
回答by Shahrukh Anwar
Follow the below steps,
按照以下步骤,
1). Open your php.ini file via sublime through path
/etc/php/7.2/apache2/php.ini
2). find display_errors in that file
3). Un-comment these lines of code
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 & ~E_STRICT & ~E_DEPRECATED
Development Value: E_ALL
Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
html_errors
Default Value: On
Development Value: On
Production value: On
4). Save the file and then type the following command in the terminal
sudo service apache2 restart
your errors are now showing in the browser
回答by Phil Rv
Use the phpinfo();
function to see the table of settings on your browser and look for the
使用该phpinfo();
功能查看浏览器上的设置表并查找
Configuration File (php.ini) Path
配置文件(php.ini)路径
and edit that file. Your computer can have multiple php.ini files, you want to edit the right one.
并编辑该文件。您的计算机可以有多个 php.ini 文件,您要编辑正确的一个。
Also check display_errors = On
, html_errors = On
and error_reporting = E_ALL
inside that file
还要检查display_errors = On
,html_errors = On
并error_reporting = E_ALL
在该文件中
Restart Apache.
重新启动阿帕奇。
回答by duri
Look at error_reporting directive in php.ini.
查看 php.ini 中的 error_reporting 指令。
回答by cl0udw4lk3r
I was just stuck on the same issue, when I've realized that I was using the open short tag form:
当我意识到我使用的是开放式短标签表单时,我只是遇到了同样的问题:
<? echo 'nothing will be print if no open_short_tag option is enabled'; ?>
You have to go to your /etc/apache2/php.ini
file and set the short_open_tag = Off
to On
, then sudo service apache2 restart
!
您必须转到您的/etc/apache2/php.ini
文件并将其设置short_open_tag = Off
为On
,然后sudo service apache2 restart
!
Cheers!
干杯!