AWstats对nginx日志分析

  1. #解压awstats软件包至/usr/local/
    tar zxvf awstats-7.6.tar.gz -C /usr/local/

#重命名awstats
mv /usr/local/awstats-7.6 /usr/local/awstats

#修改awstats属主属组
chown root.root -R /usr/local/awstats

#进入tools目录
cd /usr/local/awstats/tools/

  1. #新建站点统计配置文件
    ./awstats_configure.pl

Config file path (‘none’ to skip web server setup):
none #nginx服务器,输入’none’跳过

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y #输入y,创建一个新的统计配置

-----> 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):
#直接 “回车键”

  1. 修改www.test.com统计配置文件
    vim /etc/awstats/awstats.www.test.com.conf

    LogFile="/usr/local/nginx/logs/access.log" #50行,修改nginx日志文件位置
    DirData="/var/lib/awstats" #220行,数据目录,awstats目录默认不存在(需要创建)

创建/var/lib/awstats目录
mkdir -p /var/lib/awstats

  1. 更新分析日志文件
    /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.test.com

  2. 生成静态分析日志网页数据
    /usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www.test.com -lang=cn -dir=/usr/local/awstats/wwwroot -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl
    上述命令解释如下:
    /usr/local/awstats/tools/awstats_buildstaticpages.pl :awstats静态页面生成工具
    -update -config=www.test.com :更新配置域名
    -lang=cn :语言为中文
    dir=/usr/local/awstats/wwwroot :统计结果输出的目录
    awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl :日志更新程序的路径

  3. 建立定时任务让Awstats自动更新数据(每小时59更新)
    vim /etc/crontab
    59 * * * * root /usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www.test.com -lang=cn -dir=/usr/local/awstats/wwwroot -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl

启动crond服务
systemctl start crond.service

  1. 在nginx中建立awstats虚拟目录
    vim /usr/local/nginx/conf/nginx.conf
    #http{}标签内增添一个server{}
    server {
    listen 80;
    server_name 192.168.100.7;
    location / {
    root /usr/local/awstats/wwwroot;
    index index.html awstats.www.test.com.html;
    }
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值