1.切割日志 vi /usr/local/nginx/sbin/cut_log.sh
#!/bin/bash
time=`date +%Y%m%d`
mv /server110/logs/access.log /server110/logs/${time}.log
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
chmod +x /usr/local/nginx/sbin/cut_log.sh
2.安装配置awstats
tar zxvf /home/awstats-7.0.tar.gz -C /usr/local/
mv /usr/local/awstats-7.0 /usr/local/awstats
/usr/local/awstats/tools/awstats_config.pl //第一步输入none,第二步y创建新配置文件,第三步输入域名如www.server110.com,后面回车默认
vi /etc/awstats/awstats.www.server110.com.conf
LogFile="/server110/logs/%YYYY-0%MM-0%DD-0.log" //修改此列
mkdir /var/lib/awstats
/usr/local/nginx/sbin/cut_log.sh
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.server110.com //没报错误就成功了
3.生成静态文件
cd /usr/local/awstats/wwwroot/
mkdir server110
/usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www.server110.com -lang=cn -dir=/usr/local/awstats/wwwroot/server110/ -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl
4.修改nginx配置文件,添加一个虚拟主机
vi /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name www.hello.com;
access_log off;
location / {
root /usr/local/awstats/wwwroot;
index awstats.www.server110.com.html index.html;
}
}
5.访问
http://www.hello.com/
6.添加访问控制
/usr/local/apache/bin/htpasswd -c /usr/local/nginx/conf/.htpasswd server110
vi /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name www.hello.com;
access_log off;
auth_basic "hello everyone";
auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
location / {
root /usr/local/awstats/wwwroot;
index awstats.www.server110.com.html index.html;
}
}
OK,此为个人配置,可能有错误之处,仅作为参考使用.....
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。