网站域名为www.qikangwei.com,网站根目录为/qikangwei/,访问日志位置/qikangwei/logs/
1.切割日志
vi /usr/local/nginx/sbin/cut_log.sh
#!/bin/bash
time=`date +%Y%m%d`
mv /qikangwei/logs/access.log /qikangwei/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.qikangwei.com,后面回车默认
vi /etc/awstats/awstats.www.qikangwei.com.conf
LogFile="/qikangwei/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.qikangwei.com //没报错误就成功了
3.生成静态文件
cd /usr/local/awstats/wwwroot/
mkdir qikangwei
/usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www.qikangwei.com -lang=cn -dir=/usr/local/awstats/wwwroot/qikangwei/ -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.qikangwei.com.html index.html;
}
}
5.访问
http://www.hello.com/qikangwei
6.添加访问控制
/usr/local/apache/bin/htpasswd -c /usr/local/nginx/conf/.htpasswd qikangwei
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.qikangwei.com.html index.html;
}
}
OK,此为个人配置,可能有错误之处,仅作为参考使用.....