Overriding default PHP settings in Debian and Ubuntu

For most PHP sites the default settings in php.ini will be sufficient. However, in some circumstances you may find yourself needing to override the defaults — for example if you run a memory-hungry cron job which uses more than the default limit.

You could of course edit the php.ini file directly, but the problem with this approach is that apt will complain each time PHP is upgraded because the configuration file has changed. The solution is to create a new file at the following location:


Any configuration options added to this file will override the settings in php.ini. For example, if you wanted to switch on all errors (which you should) and ensure that they are logged instead of being displayed in the browser, you would add the following lines to local.ini:

error_reporting = E_ALL
display_errors = Off
log_errors = On

The added advantage of splitting off these configuration options into a separate file is that you can use the same file on every system and be sure that the above options will always be set correctly, regardless of the defaults.


No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.