Knowledgebase
cPanel PHP-FPM php error log rotation
Posted by Ilya Vasilenko on 20 May 2021 12:19 PM
|
|
How to set up PHP error log rotation in cPanelWhen 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/domain.com.php.error.log 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 { daily rotate 3 missingok notifempty compress create }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. | |
|