配置AWstats日志分析软件

需求描述
管理员搭建完服务器,要对网站的性能做后期的不断的分析和调整,以至达到最完美的状态。针对服务器每天的日志访问量、高峰时间、压力等等是通过日志信息系统分析。如果事前没有预估,没有给定足相应的cpu、内存。假如有一天突然高发值,服务器会直接崩溃。通过观察日志,以便在以后工作调整中提出整改方案。

简介
在httpd服务器的访问日志文件access_log中,记录了大量的客户机访问信息,通过分析这些信息,可以及时了解Web站点的访问情况,通过AWStats日志分析系统,以完成自动化的日志分析与统计工作。通过AWStats日志分析系统可用来分析Apache、 Samba、Vsftpd、IIs等服务器的访问日志信息。

实验环境
系统环境:centos7 64
服务器ip地址:192.168.40.15

搭建步骤:

一、准备工作

1.关闭防火墙及selinux

[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# vi /etc/sysconfig/selinux

[[email protected] ~]# reboot #重启Linux生效

二、搭建httpd服务

[[email protected] ~]# yum -y install httpd
[[email protected] ~]# vim /etc/httpd/conf/httpd.conf #修改主配置文件

[[email protected] ~]# systemctl start httpd #启动httpd 服务

[[email protected] ~]# echo "<h1>Hello everyone</h1>" > /usr/local/httpd/htdocs/index.html #设置默认首页

测试页面

三、搭建AWStats日志分析系统

1、配置AWstats日志分析软件

apachectl -D DUMP_MODULES | grep cgi //确认加载了cgi模块
ls /usr/local/httpd/modules/ | grep cgi //确认是否编译过cgi模块

vi /usr/local/httpd/conf/httpd.conf //手动加载
LoadModule cgid_module modules/mod_cgid.so
LoadModule cgi_module modules/mod_cgi.so

2、上传或安装AWStats软件包

[[email protected] ~]# tar xf awstats-7.6.tar.gz

[[email protected] ~]# mv awstats-7.6 /usr/local/awstats #将源码剪切至/usr/local目录下
[[email protected] ~]# cd /usr/local/awstats/tools/
[[email protected] ~]# chmod +x awstats_configure.pl #将配置脚本赋予执行权限
[[email protected] tools]# ./awstats_configure.pl

----- AWStats awstats_configure 1.0 (build 20140126) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:

  • You are not an administrator user,
  • You want to analyze downloaded log files without web server,
  • You want to analyze mail or ftp log files instead of web log files,
  • You need to analyze load balanced servers log files,
  • You want to ‘understand‘ all possible ways to use AWStats...
    Read the AWStats documentation (docs/index.html).

-----> Running OS detected: Linux, BSD or Unix

-----> Check for web server install

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

/usr/local/httpd/conf/httpd.conf
#填写网站服务器的完整配置文件路径。这里的路径是/usr/local/httpd/conf/httpd.conf
-----> Check and complete web server config file ‘/usr/local/httpd/conf/httpd.conf‘
Warning: You Apache config file contains directives to write ‘common‘ log files
This means that some features can‘t work (os, browsers and keywords detection).
Do you want me to setup Apache to write ‘combined‘ log files [y/N] ? y
#将日志格式转换成combined,显示更为详细
Add ‘Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"‘
Add ‘Alias /awstatscss "/usr/local/awstats/wwwroot/css/"‘
Add ‘Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"‘
Add ‘ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"‘
Add ‘<Directory>‘ directive
AWStats directives added to Apache config file.

-----> Update model config file ‘/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf‘
File awstats.model.conf updated.

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y
#是否需要创建AWStats的配置文件,当然"y"
-----> Define config file name to create
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.ly.com #指定要统计的目标网站名称,虚拟主机名或者自定义配置名,可以同时支持多个站点进行观测。

-----> Define config file path
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):

     #默认回车,定义配置文件路径是在/etc/awstats目录下

-----> Create config file ‘/etc/awstats/awstats.www.ly.com.conf‘
Config file /etc/awstats/awstats.www.ly.com.conf created.

-----> Restart Web server with ‘/sbin/service httpd restart‘

-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.ly.com
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...

A SIMPLE config file has been created: /etc/awstats/awstats.www.ly.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for ‘www.ly.com‘ with command:

perl awstats.pl -update -config=www.ly.com
You can also read your statistics for ‘www.ly.com‘ with URL:
http://localhost/awstats/awstats.pl?config=www.ly.com #注意访问awstats的URL

Press ENTER to finish... #默认回车退出

3、修改awstats配置文件

[[email protected] ~]# vi awstats/awstats.www.ly.com.conf //修改程序的主配置文件

LogFile="/usr/local/httpd/logs/access_log" //LogFile用来指定日志文件位置,第50行
DirData="/var/lib/awstats" //220行 手动建立每次抓取的数据存放位置

[[email protected] ~]# mkdir /var/lib/awstats #创建awstats统计数据存放目录

4.将之前的修改过的日志格式清空一下

[[email protected] ~]#cd /usr/local/httpd/logs/
[[email protected] logs]#rm -f *log #之前日志格式是common,现在使用awstats改为了combined
[[email protected] logs]#service httpd restart #重新生成日志文件

5.采集数据及访问awstats

[[email protected] ~]#cd /usr/local/awstats/tools/
[[email protected] tools]#chmod +x awstats_updateall.pl
[[email protected] tools]#./awstats_updateall.pl now //手动采集/跟新一次数据

接下来访问下页面

再次手动采集

http://192.168.40.15/awstats/awstats.pl?config=www.ly.com

6、跟新手动不方便,借助于计划任务执行:

[[email protected] tools]# crontab -e #编辑周期性任务计划

/5 * /usr/local/awstats/tools/awstats_updateall.pl now

crontab -l
service crond status
systemctl enable crond
systemctl list-unit-files | grep crond

7、通过配置页面自动跳转优化统计页面访问

[[email protected] ~]#vi /usr/local/httpd/htdocs/aw.html #创建跳转页面

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

8、设置awstats网页访问认证
[[email protected] ~]# vim /usr/local/httpd/conf/httpd.conf

原文地址:http://blog.51cto.com/13871378/2313601

时间: 2024-08-02 10:34:23

配置AWstats日志分析软件的相关文章

AWStats日志

实验2配置AWStats日志分析系统 实验环境 在虚拟机Linux 6.5系统下需要2台Linux系统一台A作为服务端一条B作为测试客户端win7真实主机开启2台Linux系统. 实验目标 A作为服务端配置VSFTPD服务器实现FTP服务. B作为测试客户端验证服务器A的共享是否有效. 配置真实主机确保真实主机能ping通2台虚拟机. 实验步骤 1.首先将A,B真实主机放到同一网段中为了以后实验方便配置永久起效的静态IP地址验证AB真实主机能否通信安装Awstats并为要统计的站点建立配置文件.

nginx awstats 安装配置和日志分析

1.Nginx安装目录:/usr/local/nginx Nginx配置文件存放目录:/usr/local/nginx/conf/nginx.conf Nginx日志目录:/usr/local/nginx/logs Awstats安装目录:/usr/local/awstats Awstats配置文件存放目录:/etc/awstats 日志切割脚本存放目录:/usr/local/nginx/nginx_log.sh 2.Nginx日志切割 修改nginx.conf配置文件,使AWSTATS支持分析

Apache配置与应用——AWStats日志分析系统(实战!)

AWStats日志分析系统 Perl语言开发的一款开源日志分析系统 可用来分析Apache,Samba,Vsftpd,IIS等服务器的访问日志 信息结合crond等计划任务服务,可对日志内容定期进行分析 环境 一台Linux服务主机(192.168.13.132) 一台win7测试pc机 1,yum安装http和bind服务 [[email protected] ~]# yum install httpd bind -y 2,配置DNS配置文件 [[email protected] ~]# vi

AWStats日志分析工具

awstats官方网站:http://awstats.sourceforge.net/ perl官方网站:http://www.perl.com/ Awstats是一个非常简洁而且强大的统计工具.它可以统计您站点的如下信息: 一:访问量,访问次数,页面浏览量,点击数,数据流量等精确到每月.每日.每小时的数据二:访问者国家.访问者IP.操作系统.浏览器等三:Robots/Spiders的统计四:纺客持续时间五:对不同Files type 的统计信息六:Pages-URL的统计七:其它信息(搜索关键

seci-log 1.02 发布,日志分析软件增加了多种告警

我们在日志分析软件七种告警(非上班时间访问,非上班地点访问,密码猜测,账号猜测,账号猜测成功.敏感文件操作告警和高危命令操作)的基础上有增加了主机扫描,端口扫描,非法外联告警的内容. 主机扫描 主机扫描是指在一台机器上对内网或者外网一个网段进行扫描,目的是要发现网络中存活的主机,为下一步的操作打下基础.这条告警和下面的端口扫描和非法外联都属于网络层面的告警,前提也是需要配置日志策略.在linux系统中大部分都内置了iptabe防火墙,可以利用iptable防火墙的日志功能进行采集日志,然后进行分

seci-log 1.11 发布,日志分析软件增加 ftpserver 等功能

日志分析软件 seci-log 1.11发布,增加了增加了ftpserver,远程ftp,sftp采集简化配置等功能. 配置文件application.properties做了简化操作. 1.对系统用到的端口采用了默认处理,这样可以不需要在配置端口了. 2.本机ip如果不配置,则获取本机第一块网卡的ip地址. 3.增加了server=syslog|remote|file|ftpserver|snmp的配置,通过减少里面的内容可以启动部分内容,也可以拆分出来进行多进程启动. 取消了file.pro

AWStats日志分析系统

部署AWStats日志分析系统 AWStats可以为Apache,samba,vsftpd,IIS等服务进行日志分析 这里我们对Apache网站进行日志分析 安装AWStats软件包 为要统计的站点建立配置文件 进入交互式操作 之后的几步都是按Enter键 画箭头上方的路径是我们配置为之后,要访问的AWStats日志分析系统的页面. 修改站点统计配置文件      (指定日志路径) 需添加                       (统计数据的目录) 可以查找到 创建目录 更新所有的站点 创建

seci-log 开源日志分析软件发布了

随着互联网和云计算的发展,公有云服务器是人们越来越容易接受的产品,其最普遍受益的一点就是节省成本.企业不必像拥有私有云那样去购买,安装,操作或运维服务器或是其他设备.在一个公有云的服务供应商提供的平台上,企业只需使用或开发他们自己的应用程序即可.但公有云的安全问题也是显而易见的,基于Internet的公有云服务的特性,全世界只要能上网的人就可以访问到其云服务器,其在云主机及其云上的数据受到威胁会更多而且更复杂,数据相对于私有云处于一个不稳定的状态.不管是传统的信息化还是未来趋势的云计算,都面临着

nginx日志分析 Awstats日志工具

很多PHP搭建的网站都在由apache转向了nginx.nginx的日志信息如何分析呢?推荐一款结果信息非常详尽的开源工具——Awstats ,它基于perl编写,它的介绍如下: AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a