欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Linux---Awstats日志分析

程序员文章站 2022-06-25 20:27:50
...

Linux—Awstats日志分析

一.AWStats日志分析系统

1.Perl语言开发的一款开源日志分析系统

2.可用来分析Apache,Samba,Vsftpd,IIS等服务器的访问日志

3.信息结合crond等计划任务服务,可对日志内容定期进行分析

二.Awstats日志分析实验

1.安装服务
[aaa@qq.com ~]# yum install bind httpd -y
2.配置DNS
主配置文件:
[aaa@qq.com ~]# vim /etc/named.conf 

Linux---Awstats日志分析

区域配置文件:
[aaa@qq.com ~]# vim /etc/named.rfc1912.zones 

Linux---Awstats日志分析

区域数据配置文件:
[aaa@qq.com named]# ls
data  dynamic  named.ca  named.empty  named.localhost  named.loopback  slaves
[aaa@qq.com named]# cp -p named.localhost kgc.com.zone
[aaa@qq.com named]# vim kgc.com.zone 

Linux---Awstats日志分析

开启服务:
[aaa@qq.com named]# systemctl start named
3.配置Ahache:
配置文件:
[aaa@qq.com named]# vim /etc/httpd/conf/httpd.conf 

Linux---Awstats日志分析

Linux---Awstats日志分析

关防火墙,开服务:
[aaa@qq.com named]# systemctl stop firewalld.service 
[aaa@qq.com named]# setenforce 0
[aaa@qq.com named]# systemctl start httpd
4.解析,并访问:
[aaa@qq.com ~]# systemctl stop firewalld.service 
[aaa@qq.com ~]# setenforce 0
[aaa@qq.com ~]# vim /etc/resolv.conf 
[aaa@qq.com ~]# 

Linux---Awstats日志分析

Linux---Awstats日志分析

5.准备安装包,并解压:
[aaa@qq.com ~]# rz

[aaa@qq.com ~]# ls
anaconda-ks.cfg     initial-setup-ks.cfg  模板  图片  下载  桌面
awstats-7.6.tar.gz  公共                  视频  文档  音乐
[aaa@qq.com ~]# tar zxvf awstats-7.6.tar.gz -C /opt/
6.把包移到/usr/local下,并重命名:
[aaa@qq.com ~]# mv /opt/awstats-7.6 /usr/local/awstats
7.用脚本配置Apache文件:
[aaa@qq.com opt]# cd /usr/local/awstats/tools
[aaa@qq.com tools]# ls
awstats_buildstaticpages.pl  awstats_updateall.pl  httpd_conf          nginx               xslt
awstats_configure.pl         dolibarr              logresolvemerge.pl  urlaliasbuilder.pl
awstats_exportlib.pl         geoip_generator.pl    maillogconvert.pl   webmin
[aaa@qq.com tools]# ./awstats_configure.pl

Linux---Awstats日志分析

Linux---Awstats日志分析

配置Apache:
[aaa@qq.com tools]# vim /etc/httpd/conf/httpd.conf

Linux---Awstats日志分析

[aaa@qq.com tools]# vim /etc/awstats/awstats.www.kgc.com.conf
[aaa@qq.com tools]# mkdir /var/lib/awstats
修改访问日志文件位置:
LogFile="/var/log/httpd/access_log"

DirData="/var/lib/awstats"
8.重启服务并查看
[aaa@qq.com tools]# systemctl restart httpd.service 

Linux---Awstats日志分析

9.更新数据,并查看:
[aaa@qq.com tools]# ./awstats_updateall.pl now
Running '"/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=www.kgc.com -configdir="/etc/awstats"' to update config www.kgc.com
Create/Update database for config "/etc/awstats/awstats.www.kgc.com.conf" by AWStats version 7.6 (build 20161204)
From data in log file "/var/log/httpd/access_log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 12
 Found 0 dropped records,
 Found 0 comments,
 Found 0 blank records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 12 new qualified records.

Linux---Awstats日志分析

10.计划性任务更新数据
[aaa@qq.com tools]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab

*/5 * * * *  /usr/local/awstats/tools/awstats_updateall.pl now
11.优化网页地址:
[aaa@qq.com tools]# cd /var/www/html/
[aaa@qq.com html]# vim aws.html

<html>
 <head>
   <meta http-equiv=refresh content="0;url=http://www.kgc.com/awstats/awstats.pl?config=www.kgc.com">
 </head>
 <body></body>
</html>
12.用直接用www.kgc.com/aws.html访问

Linux---Awstats日志分析

相关标签: LINUX