Aws万岁爷 2019-11-10
PerI语言开发的一款开源日志分析系统
可用来分析Apache、Samba、 Vsftpd、 IIS等 服务器的访问日志
信息结合crond等计划任务服务,可对日志内容定期进行分析
[ ~]# yum install bind httpd -y
修改DNS主配置文件
[ ~]# 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; }; //允许所有
修改区域配置文件
[ ~]# 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; };
};
修改区域数据配置文件
[ ~]# cd /var/named/
[ named]# cp -p named.localhost kgc.com.zone
//复制一份模板作为区域数据配置文件
[ 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 //添加域名解析地址为本机地址[ named]# systemctl start named
修改http主配置文件
[ html]# vim /etc/httpd/conf/httpd.conf //进入httpd配置文件
Listen 192.168.131.129:80 //修改ipv4监听地址为本机IP
#Listen 80 //将ipv6端口注释
ServerName www.kgc.com:80 //修改域名
[ named]# systemctl stop firewalld.service //关闭防火墙
[ named]# setenforce 0 //关闭增强型安全功能
[ html]# systemctl start httpd.service //启动httpd服务
用测试机(dns服务地址192.168.131.129)访问测试网站
此时再进入服务器查看日志文件,即可查看到有哪些主机访问了我们的网站
[ aaa]# mkdir /aaa //创建本地挂载目录
[ ~]# mount.cifs //192.168.100.3/LAMP /aaa //远程挂载文件到本地
Password for //192.168.10.37/LAMP:
[ aaa]# cd /aaa //进入挂载点/aaa
[ aaa]# tar zxvf awstats-7.6.tar.gz -C /opt/ //将awstats工具包解压到本地/opt目录
[ aaa]# ls /opt
awstats-7.6 rh
[ aaa]# cd /opt
[ opt]# mv awstats-7.6/ /usr/local/awstat
//移动awstats工具包到/usr/local/awsta
[ opt]# ls /usr/local/ //查看目录中是否有awstat文件awstat etc include lib64 sbin src
bin games lib libexec share[ 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
[ opt]# cd /usr/local/awstat/tools/ //进入目录
[ 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..
[ tools]# vim /etc/httpd/conf/httpd.conf
...
366 <Directory "/usr/local/awstat/wwwroot">
367 Options None
368 AllowOverride None
369 Order allow,deny
370 Allow from all
371 Require all granted //在此行插入此行条目用以允许所有访问
372 </Directory>
[ tools]# ls /etc/awstats/
awstats.www.kgc.com.conf
[ tools]# vim /etc/awstats/awstats.www.kgc.com.conf
LogFile="/var/log/httpd/access_log"
使用/LogFile查找到关键词所在行,将末尾改为access_log
[ tools]# cd /var/lib/
[ lib]# mkdir awstats
[ lib]# systemctl stop httpd
[ lib]# systemctl start httpd
[ tools]# cd /var/www/html/ //进入站点目录
[ html]# vim aws.html //创建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>[ html]# ls
aws.html
此时我们只需要在测试机访问www.kgc.com/AWS.html 即可访问到统计页面了