Questions? Feedback? powered by Olark live chat software
Author Avatar

cPanel PHP-FPM php error log rotation

Written by: on 20 May 2021 12:19 PM 20 May 2021 12:19 PM

How to set up PHP error log rotation in cPanel

When cPanel server uses PHP-FPM it does only control the log rotation for system-like log files, which are sitting at /opt/cpanel/ea-phpXY

However it does not rotate PHP error log generated and stored at /home/<user>/logs/

Modern CMSes may produce huge amount of Warning and Deprecated log entries in those files.

To setup log rotation for mentioned log files you need to create a new logrotate unit.

Example file name: /etc/logrotate.d/custom_php-fpm_error_log

File content:
/home/*/logs/*php.error.log {
	rotate 3
This unit will run daily, rotate log file, compress it, keep last 3 rotated files, and create a new empty log file with correct owner/permissions.
(4 vote(s))
Not helpful