Linux(nginx)下安装awstats日志分析软件
这里用的是centos的系统,linux上的安装方法基本上都一样的.
一.下载awstats软件
从地址可以下载,这里使用的是最新的7.0的版本
#cd /usr/local #wget http://cdnetworks-kr-1.dl.sourceforge.net/project/awstats/AWStats/7.0/awstats-7.0.zip#unzip awstats-7.0.zip awstats #chmod +x /usr/local/awstats/tools/awstats_configure.pl #chmod +x /usr/local/awstats/wwwroot/cgi-bin/awstats.pl #chmod +x /usr/local/awstats/tools/awstats_buildstaticpages.pl #用来存放swstats的数据文件 #mkdir /var/lib/awstats
二.创建配置文件
#cd /usr/local/awstats/tools/ #perl ./awstats_configure.pl
根据提示信息进行相应的操作即可.好像第一步让输入web的配置文件,由于这里用的是nginx.不是apache的.所以输入none跳过即可.
在后面提示的域名里我们输入我们要分析的域名,如 www.haohtml.com
这里会自动创建/etc/awstats/awstats.www.haohtml.com.conf配置文件.里面有些日志文件的路径我们需要修改为实际日志的路径即可.还有日志的默认格式的,要写成
LogFormat=”%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot”
这种格式才可以的.
我这里web的日志位置在/var/log/httpd/haohtml/access.log
三.配置Nginx
为了方便,我们直接以独立域名的形式访问,如 http://awstats.haohtml.com
配置如下:
server { server_name awstats.haohtml.com; charset gb2312;
…… root /data/wwwroot/awstats;
access_log /var/log/httpd/haohtml/access.log;
#这里将日志关闭 access_log off;
}
重启Nginx,便虚拟主机配置生效.如果对虚拟主机配置不懂的话,可以参考:
四.定时分割日志文件
#vi /root/cut_nginx_log.sh #!/bin/bash mv /var/log/httpd/haothml/access.log /var/log/httpd/haothml/access_$(date -d “today” +”%Y%m%d”).log kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
By admin
read more