如何使用Awstats日志分析
admin
2023-02-28 11:21:15
0

AWStats日志分析系统

PerI语言开发的一款开源日志分析系统
可用来分析Apache、Samba、 Vsftpd、 IIS等 服务器的访问日志
信息结合crond等计划任务服务,可对日志内容定期进行分析

安装并配置Apache与DNS服务

[root@localhost ~]# yum install bind httpd -y

修改DNS主配置文件

[root@localhost ~]# vim /etc/named.conf           //进入DNS主配置文件

options {
listen-on port 53 { any; };          //将本机监听为所有
listen-on-v6 port 53 { ::1; };
directory       "/var/named";
dump-file       "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file  "/var/named/data/named.recursing";
secroots-file   "/var/named/data/named.secroots";
allow-query     { any; };                //允许所有

修改区域配置文件                            

[root@localhost ~]# vim /etc/named.rfc1912.zones            修改区域配置文件
zone "localhost" IN {                              //复制一份模板
type master;
file "named.localhost";
allow-update { none; };
};

zone "kgc.com" IN {                          //修改localhost为kgc.com
type master;
file "kgc.com.zone";              //写入区域数据配置文件名称
allow-update { none; };
};

修改区域数据配置文件

[root@localhost ~]# cd /var/named/
[root@localhost named]# cp -p named.localhost kgc.com.zone          
//复制一份模板作为区域数据配置文件
[root@localhost named]# vim kgc.com.zone

$TTL 1D
@       IN SOA  @ rname.invalid. (
0       ; serial
1D      ; refresh
1H      ; retry
1W      ; expire
3H )    ; minimum
NS      @
A       127.0.0.1
www IN  A       192.168.131.129             //添加域名解析地址为本机地址

[root@localhost named]# systemctl start named

修改http主配置文件
[root@localhost html]# vim /etc/httpd/conf/httpd.conf        //进入httpd配置文件
Listen 192.168.131.129:80               //修改ipv4监听地址为本机IP
#Listen 80        //将ipv6端口注释
ServerName www.kgc.com:80          //修改域名
[root@localhost named]# systemctl stop firewalld.service        //关闭防火墙
[root@localhost named]# setenforce 0          //关闭增强型安全功能
[root@localhost html]# systemctl start httpd.service          //启动httpd服务

用测试机(dns服务地址192.168.131.129)访问测试网站
如何使用Awstats日志分析

如何使用Awstats日志分析

此时再进入服务器查看日志文件,即可查看到有哪些主机访问了我们的网站
如何使用Awstats日志分析

远程挂载并安装Awstats工具包

[root@localhost aaa]# mkdir /aaa               //创建本地挂载目录
[root@localhost ~]# mount.cifs //192.168.100.3/LAMP /aaa                  //远程挂载文件到本地
Password for root@//192.168.10.37/LAMP:
[root@localhost aaa]# cd /aaa                    //进入挂载点/aaa
[root@localhost aaa]# tar zxvf awstats-7.6.tar.gz -C /opt/                             //将awstats工具包解压到本地/opt目录
[root@localhost aaa]# ls /opt
awstats-7.6  rh
[root@localhost aaa]# cd /opt
[root@localhost opt]# mv awstats-7.6/ /usr/local/awstat
//移动awstats工具包到/usr/local/awsta
[root@localhost opt]# ls /usr/local/        //查看目录中是否有awstat文件

awstat  etc    include  lib64    sbin   src
bin     games  lib      libexec  share

[root@localhost opt]# ls /usr/local/awstat/tools/       //查看此目录下中是否有awstats_configure.pl 文件

awstats_buildstaticpages.pl  logresolvemerge.pl
awstats_configure.pl         maillogconvert.pl
awstats_exportlib.pl         nginx
awstats_updateall.pl         urlaliasbuilder.pl
dolibarr                     webmin
geoip_generator.pl           xslt
httpd_conf
[root@localhost opt]# cd /usr/local/awstat/tools/       //进入目录
[root@localhost tools]# ./awstats_configure.pl           //开始配置文件
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):

/etc/httpd/conf/httpd.conf    
//填写配置文件路径
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y             //确定创建新的配置文件

What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:

www.kgc.com                      // 输入网站域名

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):

//回车默认域名对应的配置文件目录

http://localhost/awstats/awstats.pl?config=www.kgc.com
//此网页即为我们的要访问的网址
Press ENTER to finish..

修改Apache配置文件

[root@localhost tools]# vim /etc/httpd/conf/httpd.conf
...
366
367     Options None
368     AllowOverride None
369     Order allow,deny
370     Allow from all
371         Require all granted         //在此行插入此行条目用以允许所有访问
372

修改awstats配置文件

[root@localhost tools]# ls /etc/awstats/
awstats.www.kgc.com.conf
[root@localhost tools]# vim /etc/awstats/awstats.www.kgc.com.conf
LogFile="/var/log/httpd/access_log"
使用/LogFile查找到关键词所在行,将末尾改为access_log

为awstats创建文件夹并重启服务

[root@localhost tools]# cd /var/lib/
[root@localhost lib]# mkdir awstats
[root@localhost lib]# systemctl stop httpd
[root@localhost lib]# systemctl start httpd

将网站地址进行优化并使用客户机进行访问

[root@localhost tools]# cd /var/www/html/       //进入站点目录
[root@localhost html]# vim aws.html     //创建aws.html网页,并将原本服战的网页链接放入即可


 


[root@localhost html]# ls
aws.html

此时我们只需要在测试机访问www.kgc.com/AWS.html 即可访问到统计页面了
如何使用Awstats日志分析

相关内容

热门资讯

国家防总提升针对广东的应急响应... 今年第12号台风“红霞”已于7月25日早晨加强为台风级。预计,“红霞”将于25日夜间至26日早晨在香...
美媒爆猛料:两国首次直接袭击伊... 多名知情人士向美国《华尔街日报》透露,巴林和科威特在7月初对伊朗境内军事目标实施了秘密空袭,知情人士...
郑丽文:只有中国国民党可以确保... 据凤凰卫视报道,国民党今天(7月25日)举行“全代会”,党主席郑丽文与党内提名的县市长参选人一同造势...
透视上半年消费外贸外资走势 新华社北京7月23日电 题:稳中提质 韧性增强——透视上半年消费外贸外资走势新华社记者谢希瑶、王聿昊...
水龙头出水小怎么解决 水龙头出水小可能是由多种原因引起的,以下是一些常见的解决方法:1. 清洁水龙头:水龙头使用时间长了,...
小神童洗衣机启动后不出水直接洗 有可能是洗衣机的进水阀被烧坏了,需要换一个新的进水阀安装上即可。另外不建议自己擅自拆卸洗衣机内部进行...
祝贺景德镇! 海报制作:苗夏阳正在韩国釜山举行的联合国教科文组织第48届世界遗产大会25日通过决议将“景德镇手工瓷...
中央空调不制冷怎么办-中央空调... 中央空调,是电器股份有限公司主要产品之一,但是由于中央空调使用环境和使用方式的不同,在使用过程中就会...
空调不出水不制冷怎么回事 内罩长期不清洗,当然房间密封性差的话也会导致这种现象;其次就是外机问题,如果外机积满灰尘,会成空调制...
空调不出水,不制冷 原因有多种,可能是电源插头没有接牢、制冷剂不足、空调短时间休息间隙、空调滤网积灰等等。很多情况可以自...