Disable display_errors as default

Hello,

I’m trying to disable display_errors in php.ini for all sites by default. Currently, it is turned off in php.ini:

# cat /etc/php/8.4/fpm/php.ini | grep display_error
; display_errors
display_errors = Off
; separately from display_errors. We strongly recommend you set this to 'off'

If I do a phpinfo(); on a website of mine, the local and global config for display_errors is set to 1.

Currently, this directive is neither declared in the vhosts or fpm-pool-Configs. The only way to disable display_errors is to create a local .user.ini on every vHost, which is a little bit annoying. Is there a way to disable display_errors on the whole system?

Thanks in advance!

Hi,

Double check whether another .ini file is enabling display_errors.

grep -ri display_errors /etc/php/8.4/fpm/

Did you restart PHP 8.4 service?

systemctl restart php8.4-fpm

Are you sure your sites are using PHP 8.4?

Thank you for your response.

I’ve done the following:

# grep -ri display_errors /etc/php/8.4/fpm/
/etc/php/8.4/fpm/php.ini:; display_errors
/etc/php/8.4/fpm/php.ini:display_errors = Off
/etc/php/8.4/fpm/php.ini:; separately from display_errors. We strongly recommend you set this to 'off'

Also restarted PHP-FPM 8.4:

# systemctl restart php8.4-fpm

After that, I’ve created a test file:

# cat /home/lucasg/web/domain.de/public_html/test.php
<?php

phpinfo();

As far as visible, it is PHP 8.4 and also enabled display_errors:

There is no special config for this domain; it is the default web domain template from hestiaCP.

Show the output of these commands:

grep -Eri 'user_ini.filename' /etc/php/8.4/fpm
find /home/*/web/ -name '.user.ini' -print0 | xargs -0 grep display_errors

If the first command only shows this:

/etc/php/8.4/fpm/php.ini:;user_ini.filename = ".user.ini"
/etc/php/8.4/fpm/php.ini:;user_ini.filename =

Edit /etc/php/8.4/fpm/php.ini and uncomment the line ;user_ini.filename = (remove ;) and after that, save the file, restart the service and try again:

systemctl restart php8.4-fpm

I’ve tried first to create a .user.ini:

# cat /home/lucasg/web/domain.de/public_html/.user.ini
display_errors = Off

This leads to a working local value of display_errors = off.

The interesting thing is, that this works, even if the user_ini directive is commented out:

# grep -Eri 'user_ini.filename' /etc/php/8.4/fpm
/etc/php/8.4/fpm/php.ini:;user_ini.filename = ".user.ini"
/etc/php/8.4/fpm/php.ini:;user_ini.filename =

The find command doesn’t give any results besides my test .user.ini mentioned in this post. I’ve removed this .user.ini, removed the semicolon in the php.ini and restarted php-fpm. display_errors is “on” again.

It works because if the directive is commented out it uses .user.ini by default.

Then I’m sorry but I don’t know what’s enabling the directive display_errors :frowning: