Author Topic: How to limit the size of the error log Apache ?  (Read 71 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
How to limit the size of the error log Apache ?
« on: August 16, 2025, 12:24:38 PM »
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.


Offline
*****
Re: How to limit the size of the error log Apache ?
« Reply #1 on: August 16, 2025, 01:12:34 PM »
Enable logrotate to keep your logs to a manageable size.
If you don't need to save them, first start by truncating your apache error & access logs to zero bytes:
Code: [Select]
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):
Code: [Select]
truncate -s0 /usr/local/cwpsrv/logs/*_logAlso, 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):
Code: [Select]
/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
}