/ mozey.co / blog

php cli error log

November 1, 2015

🔗 Setup php_errors.log for CLI on Ubuntu 16.04

Check if error_log is set

php -i | grep error

Find path to php.ini

php -i | grep Configuration

Enable error logging

sudo vi /etc/php/7.0/cli/php.ini
#log_errors = On
#error_log = /var/log/php_errors.log
#error_reporting = E_ALL | E_STRICT    

🔗 Setup php_errors.log for CLI on Ubuntu 12.04

Enable error logging

sudo vi /etc/php5/cli/php.ini

log_errors = On
error_log = /var/log/php_errors.log
error_reporting = E_ALL | E_STRICT

Create error log and set permissions

sudo touch /var/log/php_errors.log

sudo chmod g+w /var/log/php_errors.log

Assuming the PHP CLI scripts will be running as the ubuntu user

sudo chgrp ubuntu /var/log/php_errors.log