apache上使用awstats日志分析系统

AWStats日志分析系统

perl语言开发的一款开源日志分析系统

可用来分析apache samba vsftpd IIS等服务日志

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

apache

[root@localhost ~]# yum -y install httpd &>/dev/null
[root@localhost ~]# rpm -qc httpd
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd

开启httpd服务

# 或者使用service httpd start
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# netstat -antp | grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      32864/httpd         
tcp6       0      0 192.168.218.6:80        192.168.218.1:58303     FIN_WAIT2   32867/httpd         

安装awstats

[root@localhost ~]# tar -xf awstats-7.6.tar.gz 
# 重命名并放到/usr/local目录下
# 重命名把版本号去掉,因为遇过在后面的配置中找不到文件路径的情况
[root@localhost ~]# mv awstats-7.6 /usr/local/awstats
[root@localhost ~]# cd /usr/local/awstats/tools/
[root@localhost tools]# ./awstats_configure.pl 
……省略部分信息……
Config file path ('none' to skip web server setup):
> /etc/httpd/conf/httpd.conf  # 填入httpd的配置文件路径
……省略部分信息……
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y
……省略部分信息……
Your web site, virtual server or profile name:
> www.awtest.com
……省略部分信息……
Directory path to store config file(s) (Enter for default):
> 
……省略部分信息……
Press ENTER to continue... 
……省略部分信息……
Press ENTER to finish...

查看httpd配置文件

[root@localhost tools]# vim /usr/local/httpd/conf/httpd.conf
……省略部分信息……
# 在文件最后会自动添加以下信息
<Directory "/usr/local/awstats/wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

自动添加的配置为日志web页面,视情况修改权限

<Directory "/usr/local/awstats/wwwroot">
    Options None
    AllowOverride None
#    Order allow,deny
#    Allow from all
    Require all granted
</Directory>

修改awstats站点统计配置文件

[root@localhost tools]# vim /etc/awstats/awstats.www.awtest.com.conf 
LogFile="/var/log/httpd/access_log"  
# 同样根据实际情况配置
# yum安装的httpd的日志文件和源码安装的日志文件位置不一样

重启httpd服务、手动刷新awstats数据

[root@localhost tools]# systemctl restart httpd
# 手动创建数据文件目录
[root@localhost tools]# mkdir /var/lib/awstats
# 手动刷新数据
[root@localhost tools]# ./awstats_updateall.pl now
Running '"/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=www.com -configdir="/etc/awstats"' to update config www.awtest.com
……省略部分信息……
Jumped lines in file: 0
Parsed lines in file: 5
 Found 0 dropped records,
 Found 0 comments,
 Found 0 blank records,
 Found 4 corrupted records,
 Found 0 old records,
 Found 1 new qualified records.

访问效果

http://www.awtest.com/awstats/awstats.pl?config=www.awtest.com

在这里插入图片描述

添加crontab计划任务

# 每三分钟刷新
[root@localhost ~]# crontab -e
*/3 * * * * /usr/local/awstats/tools/awstats_updateall.pl now

优化网页地址

添加网页文件/var/www/html/aws.html

<html>
  <head>
    <meta http-equiv=refresh content="0;url=http://www.awtest.com/awstats/awstats.pl?config=www.awtest.com">
  </head>
</html>

访问http://www.awtest.com/aws.html便将跳转到http://www.awtest.com/awstats/awstats.pl?config=www.awtest.com

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值