centos + nginx + awstats

博客已经搬家,请访问如下地址:http://www.czhphp.com

wget http://nchc.dl.sourceforge.net/sourceforge/awstats/awstats-6.9.tar.gz
tar zxvf awstats-6.9.tar.gz
mv awstats-6.9/ /usr/local/
cd /usr/local/awstats-6.9/tools/
./awstats_configure.pl

Do you want to continue setup from this NON standard directory [yN] ?

y

Config file path ('none' to skip web server setup):

>none

file (required if first install) [y/N] ?

y

Example: demo
Your web site, virtual server or profile name:
>test.openx.cn

-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
>Enter(安默认的,配置文件保存在/etc/awstats)
 
 
 

vim /etc/awstats/awstats.test.openx.cn.conf

替换下面配置:
LogFile="/home/wwwlogs/access_%YYYY-24%MM-24%DD-24.log"

三,开始分析、生成结果

最后,可以执行分析了。

使用这个命令:
/usr/local/awstats-6.9/tools/wwwroot/cgi-bin/awstats.pl -update -config=test.openx.cn
 

这个命令会把结果生成到/var/lib/awstats 目录下 awstatsXXXX.www.XXXX.com.txt文件。

当然这样看起来不太方便,可以再用下面的命令来生成html页面,更加直观。

/usr/local/awstats-6.9/tools/awstats_buildstaticpages.pl -update -config=test.openx.cn -lang=cn -dir=/data/awstats -awstatsprog=/usr/local/awstats-6.9/wwwroot/cgi-bin/awstats.pl

/usr/local/awstats-6.9/tools/awstats_buildstaticpages.pl -update \
 -config=www.xxxxoke.com -lang=cn \
-dir=/html/awstats \
-awstatsprog=/usr/local/awstats-6.9/tools/wwwroot/cgi-bin/awstats.pl

 

这样就会在/html/awstats目录下生成很直观的分析结果页。

 

四,自动化

要是每天都去服务器上运行几条命令肯定是件令人烦燥的事情,幸亏Linux的世界里有crontab,

下面是从网友那找的 crontab

 

1 0 * * * sh /home/zyf/sh/cut_nginx_log.sh

0 1 * * * /usr/local/awstats-6.9/wwwroot/cgi-bin/awstats.pl -update -config=www.xxxxke.com

0 2 * * * /usr/local/awstats-6.9/tools/awstats_buildstaticpages.pl -update -config=www.xxxxke.com -lang=cn -dir=/html/awstats -awstatsprog=/usr/local/awstats-6.9/tools/wwwroot/cgi-bin/awstats.pl



LogFile="/home/wwwlogs/access_%YYYY-24%MM-24%DD-24.log"

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

博客已经搬家,请访问如下地址:http://www.czhphp.com

posted @ 2012-11-28 12:31  曹振华  阅读(470)  评论(0编辑  收藏  举报