New in CWP Edge-LatestFree with every CWPpro licenceWebsites up to 300x faster

CWP now includes LSPHP, LSAPI-Cache and CWP Cage at no extra cost with all CWPpro licences. The LSAPI-Cache plugin is integrated into our WordPress and other script installers, and CWP Cage gives every user complete isolation. Available now in the CWP Edge-Latest version.

Get CWPpro ›

How to limit the size of the error log Apache ?

Started by kalybg, August 16, 2025, 12:24:38 PM

Previous topic - Next topic

kalybg

Hello,
How can I limit the size of the error log in  /usr/local/apache/domlogs/ ?
I want to set it to no more than 100 MB.

P.S. I have a compromised WordPress site for a client and in 12 hours it made my error log 155 GB. This stopped my server and even access to it. This is frivolous from a security point of view and is complete nonsense.
Please, if anyone has a normal solution, share it.

Thanks in advance.


overseer

Enable logrotate to keep your logs to a manageable size.
Quote from: overseer on January 21, 2023, 10:01:13 PM
If you don't need to save them, first start by truncating your apache error & access logs to zero bytes:
truncate -s0 /usr/local/apache/domlogs/*.error.log
truncate -s0 /usr/local/apache/domlogs/*.log

Also consider doing the same if you are sure you don't need your CWP access/error logs (for security auditing/troubleshooting):
truncate -s0 /usr/local/cwpsrv/logs/*_log
Also, look under /usr/local/cwp/php71/var/log/

To automatically rotate the logs, add a configuration to logrotate for apache logs. Put this code into /etc/logrotate.d/httpd (or use File Management > Logrotate Manager to create it):
/usr/local/apache/domlogs/*log {
    missingok
    notifempty
    sharedscripts
    daily
    rotate 7
    postrotate
        /bin/systemctl reload httpd.service > /var/log/httpd-rotate.log 2>&1 || true
    endscript
    compress
}