In addition to ".user.ini", another way to do it on production web server/system-wide is to create a /etc/php/x.x/apache2/conf.d/99-custom_overrides.ini
(or similar name) so it's read in last.
(x.x = your PHP version currently used on Apache)
Just put the directives you wish to override in that file and save it.
For example:
display_errors = Off
display_startup_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
log_errors = On
upload_max_filesize = 8M
post_max_size = 32M
Then restart webserver and recheck your phpinfo() webpage. Check the area "Additional .ini files parsed" to see if it's reading your .ini
last. If you do not see the file, you did something wrong and values will not be overridden. If you do, check same page to see the value are now being overridden.
That way you will not wipe it out on a system file update. Directly editing 'php.ini' is not advisable.
Please note: This is based on a Debian/Ubuntu package/repo version of PHP 5.x or
7.x. The conf.d
or 'scan directory' area needs to be set and adjusted if you compile it yourself.
Also answered here: https://stackoverflow.com/a/39669862/503621