We have a Fedora 6 web server that, like most web servers, has quite a few virtual hosts. We want our clients to keep their web server log data separate, so that if they want, they can view the server statistics for their website using awstats. We’ve found the easiest way to do this is to enable separate log files for each virtual host. That’s all fine and dandy, but after a while, these files can get pretty large. In order to keep them from taking up too much space, it’s a good idea to use a program like logrotate to rotate out these logs for us.
With Fedora 6, logrotate comes installed automatically, but we could have installed it via yum as root:
yum install logrotate
Logrotate should have put an entry in /etc/cron.daily, and will then be run as a daily cron job automatically. The Fedora package of logrotate will automatically rotate most of your system logs. But, as we have some “unconventional” virtual host logs we’d also like to rotate, we’ll have to set those up manually.
To setup the rotation of the virutal host logs, you can cd to /etc/logrotate.d. There you should see a file for apahce’s default logs called httpd. Just copy or modify this file for each virtual host you have. Any files in /etc/logrotate.d will be automatically read by logrotate when it runs. That’s it!