apache 记录档用 newsyslog 做压缩

Home Home
引用 | 编辑 笑笑
2011-04-12 15:32
楼主
推文 x1
最近升级 apache 到 2.2.17
发现之前 apache 1.3.41 用的每日自动压缩程式不太适用了

所以就上网找了一下,原来 FreeBSD 可以用 newsyslog 来做每日压缩

http://contest.ks.edu.tw/syshtml/freebsd-newsyslog.html

只要在 /etc/newsyslog.conf 中加上

复制程式
/var/log/httpd-access.log         640    5    *    @T00     Z /var/run/httpd.pid 30
/var/log/httpd-error.log          640    5    *    @T00     Z /var/run/httpd.pid 30

不过这个是用 GZIP 压缩,现在新的 FreeBSD 都是用 BZIP 压缩
这个压缩比比较高

所以可以改为

复制程式
/var/log/httpd-access.log         640    5    *    @T00     J /var/run/httpd.pid 30
/var/log/httpd-error.log          640    5    *    @T00     J /var/run/httpd.pid 30

如果你的网站有很多虚拟主机客户怎么办?
你可以在 /var/log 下开个 httpd 目录来放,然后对这个目前下的 log 都每日压缩
不过 newsyslog.conf 的要加上 G 的参数才可以

复制程式
/var/log/httpd/*.log         640    5    *    @T00     GJ /var/run/httpd.pid 30


献花 x0