AWStats 日志分析工具【配置分析其他服务器nginx日志】

【千篇一律介绍】
Awstats 是一个免费非常简洁而且强大有个性的统计工具。它可以统计您站点的如下信息:
① 访问量,访问次数,页面浏览量,点击数,数据流量等
② 精确到每月、每日、每小时的数据
③ 访问者国家
④ 访问者 IP
⑤ Robots/Spiders 的统计
⑥ 纺客持续时间
⑦ 对不同 Files type 的统计信息
⑧ Pages-URL 的统计
⑨ 访客操作系统浏览器等信息

从自身使用情况来说,awstats没有统计到每小时的访问人次,觉得不是太好。


【下载】
选择稳定版本,个人喜欢用rpm包,简单方便
http://prdownloads.sourceforge.net/awstats/awstats-7.0-1.noarch.rpm

【安装】
# rpm -Vvh awstats-7.0-1.noarch.rpm 
Preparing...                ########################################### [100%]
1:awstats                   ########################################### [100%]

----- AWStats 6.9 - Laurent Destailleur -----
AWStats files have been installed in /usr/local/awstats #awstats安装路径,工具,网页都在这里

If first install, follow instructions in documentation
(/usr/local/awstats/docs/index.html) to setup AWStats in 3 steps:
Step 1 : Install and Setup with awstats_configure.pl (or manually)
Step 2 : Build/Update Statistics with awstats.pl
Step 3 : Read Statistics

【配置】
#cd /usr/local/awstats/tools

# perl awstats_configure_pl  

         ----- AWStats awstats_configure 1.0 (build 1.9) (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):

> /etc/httpd/conf/httpd.conf   # 该处是apache主配置文件的路径,这里配置主要awstats用于web访问的;跟需要监控的web服务器没有关系
 
-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'

 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  #选择是不是同一创建一个新的对象配置文件,直接选择"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.deamon.com  #该处为统计对像的创建代号,可以起任意名字,如 aa.cn bb.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):

>  #直接Enter 就好,此处是将awstats的配置文件放在/etc/awstats 路径下
 
-----> Create config file '/etc/awstats/awstats.www.frank.com.conf'

 Config file /etc/awstats/awstats.www.frank.com.conf created.

 
-----> Restart Web server with '/sbin/service httpd restart' #重启apache 服务器,虽然awstats提示apache重启成功,如果你源码安装,需要手动启动下

Stopping httpd: [ OK ]
Starting httpd: [ OK ]
 
-----> 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.frank.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... #按Enter 键
 
 
A SIMPLE config file has been created: /etc/awstats/awstats.www.frank.com.conf

You should have a look inside to check and change manually main parameters.

You can then manually update your statistics for 'www.frank.com' with command:

> perl awstats.pl -update -config=www.frank.com

You can also read your statistics for 'www.frank.com' with URL:

> http://localhost/awstats/awstats.pl?config=www.frank.com

 
Press ENTER to finish...  注: 按Enter 键

【修改】
#cd  /etc/awstats

#vi awstats.www.deamon.com.conf

  LogFile="/var/log/httpd/mylog.log"
  修改为apache 的日志文件
  LogFile="/var/log/nginx/access_log.%YYYY%MM%DD-24"
#access_log.%YYYY%MM%DD-24是指用24小时前的年月日日志文件名,假如今天是20121115,获得的文件就是access_log.20121114
#############################################################################
#+我这里的目录/var/log/nginx/是通过NFS挂载需要监控WEB服务器日志目录
#+NFS设置网上一大堆,我这里就不说了
#+Nginx日志格式
  log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
  access_log  logs/access.log  access;
#############################################################################

LogType来指定日志类型,
   w代表web log file 
   F 代表ftp log file
   M 代表mail log file 
   S 代表streaming log file
默认的是监控WEB日志类型,不用修改

【生成数据目录】

#mkdir /var/lib/awstats #该目录为awstats的数据库库存放目录,默认是没有创建的


【初始化awstats数据库】

# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.deamon.com --update
此步骤有可能报权限错误,解决方法是
# chmod u+x /usr/local/awstats/tools/*.pl 



最后确保在apche 的主配置文件尾部有如下配置,默认情况下在安装配置awstats后是已经配置好了

... ... ...


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/">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

【定时执行】
# crontab -e

30 1 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.deamon.com --update >/dev/null 2>&1

【访问】
  这是您查看一下awstats 对网站的分析情况
     http://Your-IP/awstats/awstats.pl?config =www.deamon.com 


你可能感兴趣的:(工具,awstats,日志分析工具)