[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: logrotate for multiple websites



On 01/03/10 17:13, Richard Hector wrote:
Hi all,

I understand that I can setup a logrotate entry with sharedscripts, so
it will only reload apache once for all the logs in that stanza.

That's fine, until you want to have multiple stanzas.
Well, it true you can't reload apache per virtualhost (site) basis, but is not a problem.
In our case, we use local debian packages to deploy our clients'
websites, for ease of management. That means we'd like to have each one
drop its own file in logrotate.d,
On each site-available/* config file (per site) within "virtualhost" directive:

ErrorLog /var/log/apache2/"Yoursite"/error.log
CustomLog /var/log/apache2/"Yoursite"/access.log
but that means they have to be in
separate stanzas, and therefore we end up reloading apache several
times.
There is no problem with reloading apache (is not equal to restart) that the purpose of reload.

We do have a site-base package, which can rotate all the logs matching
our setup, but that has limitations too, like being unable to specify
different periods for different sites and suchlike.
Yes, you can do it on your script or manually, see bellow.
It also doesn't
really deal with sites packaged by other entities, that don't
necessarily know about (or depend on) our site-base package.

For each virtualhost create /etc/logrotate.d/apache-"yoursite", with this content (example).

/var/log/apache2/"Yoursite"/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var$
                        /etc/init.d/apache2 reload > /dev/null
                fi
        endscript
}

Does anyone have any suggestions for improving this?

That works for my 70 named virtualhost in production enviroment.
Thanks,
Your're welcome.
Richard


--

---------------------------------------------------------------------
   "You don't know where your shadow will fall",
        Somebody.-
---------------------------------------------------------------------
 Ing. Olaf Reitmaier Veracierta<olafrv@gmail.com>
---------------------------------------------------------------------
 Personal Web Page -- http://olafrv.com -- info@olafrv.com
---------------------------------------------------------------------


Reply to: