PHP 错误未显示在浏览器中 [Ubuntu 10.10]

发布于 2024-10-18 10:30:41 字数 423 浏览 4 评论 0原文

我对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

疏忽 2024-10-25 10:30:41

不要只在 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 from Off to 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.

何以心动 2024-10-25 10:30:41

我遇到了同样的问题 - 通过在两个 php.ini 文件中设置 display_errors = On 解决了这个问题。

/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini

然后重新启动 Apache:

sudo /etc/init.d/apache2 restart

希望这会有所帮助。

I had the same problem - solved it by setting display_errors = On in both php.ini files.

/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini

Then restarting Apache:

sudo /etc/init.d/apache2 restart

Hope this helps.

惯饮孤独 2024-10-25 10:30:41

为了使其工作,您应该在 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

搜索它们,因为它们已经定义并输入您想要的值。
然后重新启动 apache2 服务器,一切都会正常工作。祝你好运!

To make it work you should change the following variables in your 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!

究竟谁懂我的在乎 2024-10-25 10:30:41

编辑 /etc/php5/apache2/php.ini 后,请务必重新启动 apache。

您可以通过运行以下命令来执行此操作:

sudo service apache2 restart

After you edit /etc/php5/apache2/php.ini be sure to restart apache.

You can do so by running:

sudo service apache2 restart
深海蓝天 2024-10-25 10:30:41
  1. 首先您需要找到php.ini文件的路径
  2. 您将在指定路径/etc/php/7.0/apache2/中找到该文件。如果您更改 CLI 文件夹或 CGI 文件夹中的值,它将不起作用。
  3. 进行以下更改

display_errors = On

  1. 重新启动 apache 服务器

/etc/init.d/apache2 restart

  1. First you need to find the path to the php.ini file
  2. 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.
  3. Make the following changes

display_errors = On

  1. Restart you apache server

/etc/init.d/apache2 restart

困倦 2024-10-25 10:30:41

如果您的本地值覆盖主值,则不会更改 php.ini 中的值
查看 .htaccess 或虚拟主机配置文件中的这些变量。

...

        php_admin_value display_errors On
        php_admin_value error_reporting E_ALL
</VirtualHost>

如果编辑 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.

...

        php_admin_value display_errors On
        php_admin_value error_reporting E_ALL
</VirtualHost>

If you edit vhost, restart apache,

$ sudo service apache2 restart

.htaccess edits don't need apache to restart

-柠檬树下少年和吉他 2024-10-25 10:30:41

请按照以下步骤操作,

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

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
三生殊途 2024-10-25 10:30:41

使用 phpinfo(); 函数查看浏览器上的设置表并查找

配置文件(php.ini)路径

并编辑该文件。您的计算机可以有多个 php.ini 文件,您需要编辑正确的文件。

另请检查该文件内的 display_errors = Onhtml_errors = Onerror_reporting = E_ALL

重新启动 Apache。

Use the phpinfo(); function to see the table of settings on your browser and look for the

Configuration File (php.ini) Path

and 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 and error_reporting = E_ALL inside that file

Restart Apache.

得不到的就毁灭 2024-10-25 10:30:41

这里有很多关于如何查找和修改 php.ini 文件的答案,一般来说,这是最好的方法:在服务器配置中设置正确的设置。

但在某些情况下,使用共享主机时,您可能无法修改您的 php.ini 文件,或者您可能需要提交支持请求才能修改它,而您只是没有此权限时间为.

如果您突然需要立即打开出错的 PHP 脚本中的错误,而无需查找、修改配置并重新启动服务器,那么请尝试以下操作:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

上面发生的情况似乎很清楚,但如果您想了解更多信息:

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:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

It seems clear what's happening above, but if you want to learn more:

美人骨 2024-10-25 10:30:41

查看 php.ini 中的 error_reporting 指令。

Look at error_reporting directive in php.ini.

樱娆 2024-10-25 10:30:41

当我意识到我正在使用开放短标记形式时,我只是陷入了同样的问题:

<? echo 'nothing will be print if no open_short_tag option is enabled'; ?>

您必须转到 /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:

<? 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!

Cheers!

帅气尐潴 2024-10-25 10:30:41

它应该重叠,所以它被关闭。尝试在文本编辑器中打开并找到 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

夏末的微笑 2024-10-25 10:30:41

尝试添加 log_errors = Off 并检查 error_reporting 设置是否设置得足够高。

Try adding log_errors = Off and check the error_reporting setting whether it's set high enough.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文