Nginx – Suppressing PHP errors with Nginx and php-fpm

debian-jessienginxPHPphp-fpmphp5

Try as I may, I can't suppress error messages from PHP (using php-fpm) being displayed.

Relevant files;

/etc/php5/fpm/php.ini:display_errors = Off
/etc/php5/fpm/pool.d/www.conf:php_flag[display_errors] = off
/etc/php5/fpm/pool.d/www.conf:php_admin_flag[display_errors] = off
/etc/php5/cli/php.ini:display_errors = Off

When I call phpinfo() the output is as follows [images as links as this is my first post and therefore don't have sufficient reputation to put them inline, sorry!];

https://i.stack.imgur.com/4ttGt.png
https://i.stack.imgur.com/4LAah.png

The above shows the Configuration File Path as /etc/php5/fpm and the Loaded Configuration File as /etc/php5/fpm/php.ini. The second image shows display_errors and display_startup_errors as Off.

Which suggests that these settings have been correctly set, but loading a page with errors results in pages of errors e.g;

Unknown: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /path/to/file.php on line 651****Unknown: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /path/to/file.php on line 651

(formatted as above, so the HTML formatting is being applied)

I've also tried setting ini_set("display_errors", 0); and even error_reporting(0); to no avail.

Also, edited to add;

# php5-fpm -i | grep error
display_errors => Off => Off
display_startup_errors => Off => Off
error_append_string => no value => no value
error_log => /var/log/php_err.log => /var/log/php_err.log
error_prepend_string => no value => no value
error_reporting => 22527 => 22527
html_errors => Off => Off
ignore_repeated_errors => On => On
log_errors => On => On
log_errors_max_len => 1024 => 1024

What am I missing?

Versions are as follows;

Debian 8 Jessie

PHP 5.6.30-0+deb8u1

Nginx 1.6.2

Best Answer

Is this plain PHP or do you run code with some kind of framework?

It is rather common for recent frameworks to reconfigure error reporting on the fly and/or registering a custom error handler, so maybe something in your program reconfigures it again?