nginx php7.3-fpm不显示或记录错误

时间:2019-10-17 02:18:16

标签: php nginx

我有nginx/1.14.2使用php7.3-fpm运行多个站点。 php错误不会显示在浏览器中,也不会记录到我可以看到的任何地方。

一个典型的站点只会将错误记录到一个文件夹中,例如

server {

    listen 80;

    server_name www.example.com;
    root /var/www/www.example.com/public;

    index index.html index.php;

    access_log /var/www/www.example.com/logs/access.log;
    error_log /var/www/www.example.com/logs/error.log warn;

    .... rest of config

我设置了一个基本的PHP页面,该页面肯定会崩溃:

<?php

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

echo "this will crash";

crash;

echo self::foo();

$error = 'Always throw this error';
throw new Exception($error);

在浏览器中加载此页面时,我看到:

this will crash

我还在display_errors = On内设置了/etc/php/7.3/fpm/php.ini并重新启动了Nginx和php7.3-fpm服务。

我的error.log仍然为空,并且浏览器没有显示错误。我还需要设置什么?

0 个答案:

没有答案