博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转]用 awstats分析 Nginx 日志的一些记录
阅读量:4078 次
发布时间:2019-05-25

本文共 1773 字,大约阅读时间需要 5 分钟。

原文地址:http://www.linuxbyte.org/yong-awstats-fen-xi-nginx-ri-zhi-de-yi-xie-ji-lu.html

 

系统环境为Cenots+Nginx 详细请阅读之前的日志《 》。

Awstats 是目前最流行的日志分析工具,它提供比第三方日志更方便更详实的日志分析。

系统默认Nginx 版本为 1.0.0,日志格式 Awstats 可以直接识别,并且由logrotate 做了日志回滚,每日对日志进行截断。为了得到更准确的分析结果并且尽量少占用系统资源,我每天在凌晨分析上一天的日志,并将结果输出为纯静态文件。由于 logrotate 压缩了旧日志所以要修改logrotate 设置不压缩就日志。
修改vi /etc/logrotate.d/nginx

/var/log/nginx/*log {    daily    rotate 10 #保留10天的日志    missingok    notifempty    nocompress #就是这里默认是compress压缩日志    sharedscripts    postrotate        [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`    endscript}

下载安装Awstats

wget http://prdownloads.sourceforge.net/awstats/awstats-7.0-1.noarch.rpmrpm -ivh awstats-7.0-1.noarch.rpm

配置

cd /usr/local/awstats/toolsperl awstats_configure.pl

由于我们的web服务器是Nginx 所以 Check for web server install 我们选 none

-----> Need to create a new config file ?Do you want me to build a new AWStats config/profilefile (required if first install) [y/N] ? y #这里选Y -----> Define config file name to createWhat is the name of your web site or profile analysis ?Example: www.mysite.comExample: demoYour web site, virtual server or profile name:> www.linuxbyte.org #输入你要统计的网站的域名

编辑/etc/awstats/awstats.www.linuxbyte.org.conf

修改 LogFile 段加入网站日志的路径。

LogFile="/var/log/nginx/www.linuxbyte.org.access.log.1"

生成份分析结果的静态文件

cd /data/web/linuxbyte.org/awstatscp /usr/local/awstats/wwwroot/icon/ ./ -rf /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=www.linuxbyte.org -lang=cn -dir=/web/linuxbyte/awstats -update

自此你可以访问http://www.linuxbyte.org/awstats/awstats.www.linuxbyte.org.html 来查看分析结果。

设置crontable

30 4 * * */usr/local/awstats/tools/awstats_buildstaticpages.pl -config=www.linuxbyte.org -lang=cn -dir=/web/linuxbyte/awstats -update

每天凌晨 4:30 分析日志,因为这个时候是服务器最空闲的时段。

转载地址:http://casni.baihongyu.com/

你可能感兴趣的文章
Window
查看>>
为什么button在设置标题时要用一个方法,而不像lable一样直接用一个属性
查看>>
字符串的截取
查看>>
2. Add Two Numbers
查看>>
17. Letter Combinations of a Phone Number (DFS, String)
查看>>
93. Restore IP Addresses (DFS, String)
查看>>
19. Remove Nth Node From End of List (双指针)
查看>>
49. Group Anagrams (String, Map)
查看>>
139. Word Break (DP)
查看>>
Tensorflow入门资料
查看>>
剑指_用两个栈实现队列
查看>>
剑指_顺时针打印矩阵
查看>>
剑指_栈的压入弹出序列
查看>>
剑指_复杂链表的复制
查看>>
服务器普通用户(非管理员账户)在自己目录下安装TensorFlow
查看>>
星环后台研发实习面经
查看>>
大数相乘不能用自带大数类型
查看>>
字节跳动后端开发一面
查看>>
CentOS Tensorflow 基础环境配置
查看>>
centOS7安装FTP
查看>>