设为首页 收藏本站
查看: 1296|回复: 0

[经验分享] 配置AWStats日志分析服务器

[复制链接]

尚未签到

发表于 2015-9-16 12:54:46 | 显示全部楼层 |阅读模式
配置AWStats日志分析服务器
(2008-05-31 19:48:39)
转载
  1. 到AWStats官网下载最新的软件
  
下载地址:
http://awstats.sourceforge.net/#DOWNLOAD
在此下载最新的6.7版。
  
2. 安装
  
[iyunv@server ~]# tar -xzvf awstats-6.7.tar.gz
[iyunv@server ~]# mv awstats-6.7 /usr/local/awstats
[iyunv@server ~]# cd /usr/local/awstats/
[iyunv@server awstats]# ls -l
总计 20
drwxr-xr-x 3 400 401 4096 2006-01-29 docs
-rw-r--r-- 1 400 401 6717 2007-07-03 README.TXT
drwxr-xr-x 4 400 401 4096 2006-01-29 tools
drwxr-xr-x 7 400 401 4096 2006-01-29 wwwroot
docs是一些html格式到文档,里面有安装和使用到方法;
README.TXT是软件到介绍和权利申明等;
tools文件夹里面是一些脚本和配置文件,比如批量update的脚本、转换静态html文件的脚本、httpd.conf的配置文件等;
wwwroot文件夹里面的东西才是最重要的,下面详细介绍:
  wwwroot里面又有4个文件夹:awstats、css、js、icon、和classes。
从我的使用情况上看,有用的只有awstats和icon 文件夹。如果你是自己的服务器,自己能控制apache的服务的配置文件,那么你可以使用tools/awstats_configure.pl脚本来进行安装。你只需要指出httpd.conf的位置即可。
  
[iyunv@server awstats]# cd tools/
[iyunv@server tools]# ls
awstats_buildstaticpages.pl  awstats_updateall.pl  maillogconvert.pl   xslt
awstats_configure.pl         httpd_conf            urlaliasbuilder.pl
awstats_exportlib.pl         logresolvemerge.pl    webmin
[iyunv@server tools]# perl awstats_configure.pl
----- AWStats awstats_configure 1.0 (build 1.7) (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):
# 输入apache配置文件路径
> /etc/httpd/conf/httpd.conf
-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
  File awstats.model.conf updated.
# 是否需要为网站配置一个新的配置文件(选y)
-----> 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
-----> 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:
# 为你的站点起个名字
> tech
-----> 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.tech.conf'
Config file /etc/awstats/awstats.tech.conf created.
-----> 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=tech
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.tech.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'tech' with command:
> perl awstats.pl -update -config=tech
You can also read your statistics for 'tech' with URL:
# 这是查看此站点分析结果的页面
> http://localhost/awstats/awstats.pl?config=tech
  
Press ENTER to finish...

# 检查apache的配置文件,如果awstats的配置没有自动加入配置文件则进行下面的步骤。
# 拷贝awstats的配置文件到apache配置文件的包含目录下,或者将httpd_conf的内容直接加到apache配置文件的最后
[iyunv@server tools]# cp httpd_conf /etc/httpd/conf.d/awstats.conf
# awstats的配置文件较旧,修要做些修改
[iyunv@server tools]# vi /etc/httpd/conf.d/awstats.conf
# 加入标红的内容
# Content of this file, with correct values, can be automatically added to
# your Apache server by using the AWStats configure.pl tool.
#
#
# Directives to add to your Apache conf file to allow use of AWStats as a CGI.
# Note that path "/usr/local/awstats/" must reflect your AWStats install path.
#
Alias /awstatsclasses/ "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss/ "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons/ "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/awstats/wwwroot/cgi-bin">
  Options None
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
  
  
# 修改完后重启apache
[iyunv@server tools]# apachectl -k restart
  
# 创建/var/lib/awstats目录用来存放分析结果,并将所有权给apache用户(apache用户需要有写权限)
[iyunv@server wwwroot]# mkdir /var/lib/awstats
[iyunv@server wwwroot]# chown -R /var/lib/awstats
  
# 修改配置文件
[iyunv@server wwwroot]# vi /etc/awstats/awstats.tech.conf
  
  LogFile
指定日志文件的路径和名称,比如:
  LogFile=”/var/log/httpd/access_log&Prime;
也可以用动态的变量指定:
  对于Apache,日志格式好设置,设置成combined格式即可,日志截断麻烦一点:需要安装cronolog工具,将日志设置成按天截断:
CustomLog "|/usr/local/sbin/cronolog /var/log/httpd/access_log.%Y%m%d" combined
比如:access_log.20030326
  LogFile=”/var/log/httpd/access.log.%YYYY-24-%MM-24-%DD-24&Prime;
这样就可以自动取到上一天的日志了。
  多日志合并分析
LogFile="/usr/local/awstats/tools/logresolvemerge.pl /var/log/httpd/30.0206.vblog.log /var/log/httpd/31.0206.vblog.log|"

LogFile="/usr/local/awstats/tools/logresolvemerge.pl /var/log/httpd/*.0206.vblog.log|"
  
分析使用gzip压缩过的日志文件
LogFile="gzip -d < /var/log/httpd/access.log.gz|"
  
  LogType=W
使用web日志;
  
LogFormat=1
使用apache的combined格式的日志。
SiteDomain=”tech”
站点名称。
HostAliases=”localhost 127.0.0.1 REGEX[tech\.com$]”
如果站点有其它的域名的话也可以在这里加进来,也一并计算入内。
DirData=”/var/lib/awstats”
指定存放数据文件的目录,默认是/var/lib/awstats,注意该目录需要运行脚本的用户有写入权限。awstats默认按照月来存放文件,也就是说每个月一个文件。(注意要使用绝对路径)
该配置文件中还有很多选项,可以做一些细微的调节或者添加插件等。
接下来是要对日志进行分析,运行命令:
  [iyunv@server wwwroot]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=tech -update
Create/Update database for config "/etc/awstats/awstats.tech.conf" by AWStats version 6.7 (build 1.892)
From data in log file "/var/log/httpd/access_log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 307
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 307 new qualified records.
可以将上面命令加入cron任务,定时进行分析。


  查看:
查看也是用这个CGI脚本,也是用“config” 参数,比如:
  http://localhost/awstats/awstats.pl?config=tech






参考:http://www.chedong.com/tech/awstats.html

  • AWStats开源项目: http://awstats.sourceforge.net/
  • Webalizer开源项目:http://www.webalizer.org/
  • 日志分析工具:directory.google.com/Top/Computers/Software/Internet/Site_Management/Log_Analysis/
  • 商 业日志统计/分析工具: directory.google.com/Top/Computers/Software/Internet/Site_Management/Log_Analysis/Commercial/
  • 多站点的日志合并:www.chedong.com/tech/rotate_merge_log.html
  • 日志统计对于分析搜索引擎对站点的影响具有非常重要的意义:www.chedong.com/tech/google.html
  • AWStats插件说明:awstats.sourceforge.net/awstats_contrib.html

                                                               2008.05.31  iStone@BeiJing

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-114495-1-1.html 上篇帖子: 日志分析软件awstats的安装使用简易指南 下篇帖子: Tomcat7 开启CGI,并配置awstats日志监控
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表