Error reporting settings in php-fpm not recognized

I've been frustrated by this one several times. If you run an nginx server with php-fpm you'll be used to setting php values in the php-fpm pool file. That should supercede any values in php.ini

So with some values this works:

;;; php settings
php_flag[display_errors] = off
php_admin_value[error_log] = /home/bobthebuilder/logs/phpfpm.log
php_admin_flag[log_errors] = on

These all work fine. But if you look anywhere on the internet, it tells you you can also set error_logging there. It confidently tells you to use

php_admin_value[error_reporting] = E_ALL & ~E_WARNING & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED

…for example. But this doesn't work! You check and re-check the log files which are scrolling past at nausea-inducing rates. You try altering the values in php.ini, wordpress config files, anywhere you can try. But when you load up phpinfo, it just tells you you're wasting your time. You shout at google gemini a bit, but it tells you the same thing. Maybe you have some formatting errors, it suggests?

The trick, it seems is to use the numeric values. This works in your phpfpm pool file instead of the command above.

php_admin_value[error_reporting] = 8181

That's it. And there's a pretty handy page for calculating the masks here.

Now wouldn't it be nice if PHP had pre-set log levels so all you have to do is put error_log_level = 3 instead of invoking a bitmask calculator …

Leave a Comment