12.10 Nginx訪問日誌css
除了在主配置文件nginx.conf裏定義日誌格式外,還須要在虛擬主機配置文件中增長nginx
access_log /tmp/1.log combined_realip;bash
這裏的combined_realip就是在nginx.conf中定義的日誌格式名字日誌
12.11Nginx日誌切割ip
#! /bin/bash
d=`date -d "-1 day" +%Y%m%d`
logdir="/data/logs"
nginx_pid="/usr/local/nginx/logs/nginx.pid"
cd $logdir
for log in `ls *.log`
do
mv $log $log-$d
done
/bin/kill -HUP 'cat $nginx_pid'
計劃任務:io
0 0 * * * /bin/bash /usr/local/sbin/nginx_log_rotate.sh配置
12.12 靜態文件不記錄日誌和過時時間date
修改配置文件im
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 7d;
access_log off;
}
location ~ .*\.(js|css)$
{
expires 12h;
access_log off;
}配置文件