Appearance
PHP-FPM doesn't write to error log
There are a few things you can try to troubleshoot this issue:
- Check the permissions of the error log file to make sure that the PHP-FPM process has write permissions. Verify that the exact user running the PHP-FPM worker (e.g.,
www-data,nginx, orapache) matches the log file owner. - Check the PHP-FPM configuration file (usually
php-fpm.confor a pool file likewww.conf) to make sure that the error log file is correctly configured. Note that PHP-FPM maintains two separate logs: the daemon log (FPM process itself) and the script log (PHP application errors). Configure them as follows:- Daemon log (
php-fpm.conf):error_log = /var/log/php-fpm/error.log - Script log (pool file like
www.conf):ini[www] php_admin_value[error_log] = /var/log/php-fpm/www-error.log php_admin_flag[log_errors] = on
- Daemon log (
- Check the PHP error log configuration in the PHP INI file (usually
php.ini). Make sure that theerror_logdirective is set to the correct path and that the log file is writable by the PHP-FPM process. - Restart the PHP-FPM service to apply any changes you have made.
- Check the system logs (e.g.,
/var/log/syslogon Ubuntu) or usejournalctl -u php-fpmto see if there are any messages related to the PHP-FPM process or the error log file. - If none of these steps help, you can try increasing the PHP-FPM logging level to see if it provides any additional information about the issue. You can do this by adding the following line to the global
php-fpm.conffile:log_level = debug.
I hope this helps! Let me know if you have any other questions.