The default PHP configuration reports all errors and also notices, this could blow up the logs very fast. If you want to log only errors instead of all, including notices, you have to edit the php.ini.

Where is the php.ini configuration file located? PHP delivers us all configuration details with the phpinfo(); function, you’ll find the path to your php.ini using this function.

You could also run this command in your console, but beware: If you are using PHP-FPM your php.ini is stored on a different location.
To find the php.ini with PHP-FPM run this command:

/usr/sbin/php5-fpm -i | grep php.ini

This will give you:

Configuration File (php.ini) Path => /etc/php5/fpm
Loaded Configuration File => /etc/php5/fpm/php.ini

With a default PHP setup:

php -r "phpinfo(INFO_GENERAL);" | grep php.ini

You are using PHP only with your webserver? Simply create a new php file with this content:

<?php phpinfo(INFO_GENERAL); ?>

… and request it in your browser. Search for php.ini and you’ll find the correct path.

Now it’s time to edit the php.ini, in my case the configuration is inside /etc/php5/fpm/php.ini.

nano /etc/php5/fpm/php.ini

Default PHP configuration (try CTRL + W to search with nano for error_reporting, it’s a big config!):

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

New configuration:

error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR

Finally restart your webserver or only the php5-fpm process, depends on what you are using:

  • Apache 2: /etc/init.d/apache2 restart
  • nginx: /etc/init.d/nginx restart
  • PHP-FPM: /etc/init.d/php5-fpm restart