大家好,又见面了,我是你们的朋友全栈君。
AWStats日志分析系统介绍
1.AWStats日志分析系统
(1)Peri语言开发的一款开源日志分析系统
(2)可用来分析Apache、Samba、 Vsftpd、 IIS等服务 器的访问日志
(3)信息结合crond等计划任务服务,可对日志内容定期进行分析
部署AWStats日志分析系统
1.安装AWStats软件包
2.为要统计的站点建立配置文件
3.修改站点统计配置文件
4.执行日志分析,并设置crontab计划任务
访问AWStats分析系统
1.查看统计页面
2.设置网页自动跳转,方便访问
具体操作:
1.安装DNS和HTTP服务软件包
代码语言:javascript复制[root@localhost ~]# yum install bind httpd -y
2.DNS配置
(1)主配置文件
代码语言:javascript复制[root@localhost ~]# vim /etc/named.conf
(2)区域配置文件
代码语言:javascript复制[root@localhost ~]# vim /etc/named.rfc1912.zones
(3)区域数据配置文件
代码语言:javascript复制[root@localhost ~]# cd /var/named/
[root@localhost named]# ls
data dynamic named.ca named.empty named.localhost named.loopback slaves
[root@localhost named]# cp -p named.localhost kgc.com.zone
[root@localhost named]# vim kgc.com.zone
(4)开启DNS服务
代码语言:javascript复制[root@localhost named]# systemctl start named
3.HTTP配置
(1)配置文件
代码语言:javascript复制[root@localhost named]# vim /etc/httpd/conf/httpd.conf
(2)关闭防火墙,开启服务
代码语言:javascript复制[root@localhost named]# systemctl stop firewalld.service
[root@localhost named]# setenforce 0
[root@localhost named]# systemctl start httpd
4.Windows 10配置
(1)在win10主机上更改下DNS地址
(2)在浏览器上访问域名,保证能够进行对Apache访问
5.此时可以查看下日志文件,可以看出是来自IP地址为多少的主机来进行的访问
代码语言:javascript复制[root@localhost ~]# cd /var/log/httpd/
[root@localhost httpd]# cat access_log
192.168.124.131 - - [23/Oct/2019:22:23:33 0800] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:33 0800] "GET / HTTP/1.1" 403 4897 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:33 0800] "GET /noindex/css/bootstrap.min.css HTTP/1.1" 200 19341 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:33 0800] "GET /noindex/css/open-sans.css HTTP/1.1" 200 5081 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240
192.168.124.131 - - [23/Oct/2019:22:23:33 0800] "GET /images/poweredby.png HTTP/1.1" 200 3956 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:33 0800] "GET /images/apache_pb.gif HTTP/1.1" 200 2326 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/Light/OpenSans-Light.woff HTTP/1.1" 404 241 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/Regular/OpenSans-Regular.woff HTTP/1.1" 404 245 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/LightItalic/OpenSans-LightItalic.woff HTTP/1.1" 404 253 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/Italic/OpenSans-Italic.woff HTTP/1.1" 404 243 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/Semibold/OpenSans-Semibold.woff HTTP/1.1" 404 247 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/SemiboldItalic/OpenSans-SemiboldItalic.woff HTTP/1.1" 404 259 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/Bold/OpenSans-Bold.woff HTTP/1.1" 404 239 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/ExtraBold/OpenSans-ExtraBold.woff HTTP/1.1" 404 249 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.woff HTTP/1.1" 404 261 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/Light/OpenSans-Light.ttf HTTP/1.1" 404 240 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/LightItalic/OpenSans-LightItalic.ttf HTTP/1.1" 404 252 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/Regular/OpenSans-Regular.ttf HTTP/1.1" 404 244 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/Italic/OpenSans-Italic.ttf HTTP/1.1" 404 242 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/Semibold/OpenSans-Semibold.ttf HTTP/1.1" 404 246 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/SemiboldItalic/OpenSans-SemiboldItalic.ttf HTTP/1.1" 404 258 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/Bold/OpenSans-Bold.ttf HTTP/1.1" 404 238 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/ExtraBold/OpenSans-ExtraBold.ttf HTTP/1.1" 404 248 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.ttf HTTP/1.1" 404 260 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/BoldItalic/OpenSans-BoldItalic.woff HTTP/1.1" 404 251 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.131 - - [23/Oct/2019:22:23:34 0800] "GET /noindex/css/fonts/BoldItalic/OpenSans-BoldItalic.ttf HTTP/1.1" 404 250 "http://www.kgc.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"
192.168.124.129 - - [23/Oct/2019:22:23:41 0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
192.168.124.129 - - [23/Oct/2019:22:23:42 0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
6.远程共享并挂载
代码语言:javascript复制[root@localhost ~]# smbclient -L //192.168.100.7/
Enter SAMBAroot's password:
OS=[Windows 10 Home China 18362] Server=[Windows 10 Home China 6.3]
Sharename Type Comment
--------- ---- -------
ADMIN$ Disk 远程管理
C$ Disk 默认共享
D$ Disk 默认共享
IPC$ IPC 远程 IPC
LAMP-C7 Disk
Users Disk
脚本 Disk
Connection to 192.168.100.7 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
NetBIOS over TCP disabled -- no workgroup available
[root@localhost ~]# mount.cifs //192.168.100.7/LAMP-C7 /abc/
Password for root@//192.168.100.7/LAMP-C7:
[root@localhost ~]# cd /abc/
[root@localhost abc]# ls
apr-1.6.2.tar.gz cronolog-1.6.2-14.el7.x86_64.rpm LAMP-php5.6.txt
apr-util-1.6.0.tar.gz Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz
awstats-7.6.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11.tar.bz2
[root@localhost abc]#
7.解压缩包并移动安装包存放位置
代码语言:javascript复制[root@localhost abc]# tar zxvf awstats-7.6.tar.gz -C /opt/
[root@localhost abc]# cd /opt/
[root@localhost opt]# mv awstats-7.6/ /usr/local/awstats
[root@localhost opt]# cd /usr/local/
[root@localhost local]# ls
awstats bin etc games include lib lib64 libexec sbin share src
[root@localhost local]# cd awstats/
[root@localhost awstats]# ls
docs README.md tools wwwroot
[root@localhost awstats]# cd tools/
[root@localhost tools]# ls
awstats_buildstaticpages.pl dolibarr maillogconvert.pl xslt
awstats_configure.pl geoip_generator.pl nginx
awstats_exportlib.pl httpd_conf urlaliasbuilder.pl
awstats_updateall.pl logresolvemerge.pl webmin
8.更新数据
代码语言:javascript复制[root@localhost tools]# ./awstats_configure.pl
> /etc/httpd/conf/httpd.conf
> file (required if first install) [y/N] ? y
> www.kgc.com
9.HTTP配置文件
代码语言:javascript复制[root@localhost tools]# cd /etc/httpd/conf
[root@localhost conf]# vim httpd.conf
10.进入awstats.www.kgc.com.conf配置文件
代码语言:javascript复制[root@localhost conf]# cd /etc/awstats/
[root@localhost awstats]# ls
awstats.www.kgc.com.conf
[root@localhost awstats]# vim awstats.www.kgc.com.conf
DirData=”/var/lib/awstats” //awstats默认不存在(需要创建)
代码语言:javascript复制[root@localhost awstats]# cd /var/lib/
[root@localhost lib]# ls 查看没有awstats
创建后在查看
[root@localhost lib]# mkdir awstats
9.重启HTTP服务,在Windows10上进行访问
代码语言:javascript复制[root@localhost lib]# systemctl restart httpd
搜索:http://localhost/awstats/awstats.pl?config=www.kgc.com,会发现数值都是0,并且没有柱状图
10.更新数据
代码语言:javascript复制[root@localhost lib]# cd /usr/local/awstats/
[root@localhost awstats]# ls
docs README.md tools wwwroot
[root@localhost awstats]# cd tools/
[root@localhost tools]# ls
awstats_buildstaticpages.pl dolibarr maillogconvert.pl xslt
awstats_configure.pl geoip_generator.pl nginx
awstats_exportlib.pl httpd_conf urlaliasbuilder.pl
awstats_updateall.pl logresolvemerge.pl webmin
[root@localhost tools]# ./awstats_updateall.pl now //更新数据
11.计划性任务更新数据,并启动
代码语言:javascript复制[root@localhost tools]# crontab -e
*/5 * * * * /usr/local/awstats/tools/awstats_updateall.pl now
[root@localhost tools]# systemctl start crond
12.再去Windows10中进行访问,会有柱状图显示
13.优化网络地址,方便记忆
代码语言:javascript复制[root@localhost tools]# cd /var/www/html/
[root@localhost html]# ls
[root@localhost 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>
14.在浏览器输入: http://www.kgc.com/aws.html
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/160203.html原文链接:https://javaforall.cn