how to configure logrotate for apache log files

Problem : When you install apache from source , by default logrotate will not rotate those logs file as the path for log files are different.

Solution: You can edit httpd file under /etc/logrotate.d/ directory and insert bellow lines

/usr/local/apache/logs/*log {
    missingok
    notifempty
    sharedscripts
    postrotate
        /usr/local/apache/bin/apachectl graceful > /dev/null 2>/dev/null || true
    endscript
}

Now you can forcefully rotate log files by executing bellow commands:

logrotate -f /etc/logrotate.conf

Leave a Reply

*