Local php.ini not overriding main php.ini

If you are using PHP >= 5.3, then you can override configs per directory by creating a file called .user.ini.

In your case, I believe it's the filename that is the problem.

The name of the file is configurable in your primary php.ini as user_ini.filename. If that is set to an empty string, then the feature is disabled.


You can also do this via the command line

php --ini
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File:         /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d

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.

Example phpinfo() displaying Additional .ini parsing areas

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