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