zoukankan      html  css  js  c++  java
  • Linux 日志分析工具之awstats

    一、awstats 是什么

            官方网站: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 CGI or from command line and shows you all possible information your log contains, in few graphical webb pages. It uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS(W3C log format) and a lot of other web, proxy, wap, straming servers, mail servers and some ftp servers.

            Awstats 是一个免费的日志分析工具,用perl开发。可以用于分析各种linux下的应用程序产生的日志,包括 apache/squid/samba/resin/tomcat 等等。在这里,我们主要用它来分析apache日志。

            统计包括访问,访问者,页面,点击,高峰时间,操作系统,浏览器,搜索引擎,关键字,机器人访问,端开的链接和更多的阻力截图排序。

            Awstats是一个非常简洁而且强大的统计工具。它可以统计您站点的如下信息:

    一:访问量,访问次数,页面浏览量,点击数,数据流量等精确到每月、每日、每小时的数据
    二:访问者国家、访问者IP、操作系统、浏览器等
    三:Robots/Spiders的统计
    四:纺客持续时间
    五:对不同Files type 的统计信息
    六:Pages-URL的统计
    七:其它信息(搜索关键字等等) 

    • 访问次数、独特访客人数,

    • 访问时间和上次访问,

    • 使用者认证、最近认证的访问,

    • 每周的高峰时间(页数,点击率,每小时和一周的千字节),

    • 域名/国家的主机访客(页数,点击率,字节,269域名/国家检测, geoip 检测),

    • 主机名单,最近访问和未解析的 IP 地址名单

    • 大多数看过的进出页面,

    • 档案类型,

    • 网站压缩统计表(mod_gzip 或者 mod_deflate),

    • 使用的操作系统 (每个操作系统的页数,点击率 ,字节, 35 OS detected),

    • 使用的浏览器,

    • 机器人访问(检测 319 个机器人),

    • 蠕虫攻击 (5 个蠕虫家族),

    • 搜索引擎,利用关键词检索找到你的地址,

    • HTTP 协议错误(最近查阅没有找到的页面),

    • 其他基于 URL 的个性报导,链接参数, 涉及综合行销领域目的.

    • 贵网站被加入"最喜爱的书签".次数.

    • 屏幕大小(需要在索引页补充一些 HTML 标签).

    • 浏览器的支持比例: Java, Flash, RealG2 reader, Quicktime reader, WMA reader, PDF reader.

    • 负载平衡服务器比率集群报告.

            Awstats 的运行需要 perl 环境的支持,从awstats 官方文档来看,它对apache http server 的支持是非常完美的。如果使用的 nginx,要运行awstats有点麻烦。首先nginx对perl 的支持是比较弱的,甚至官方也不建议使用;另外在日志格式上需要修改后才能正常运行。

    awstats官方网站: http://awstats.sourceforge.net/   

    perl官方网站: http://www.perl.com/    

    awstats项目地址:http://sourceforge.net/projects/awstats/

    二、awstats 工作原理以及其他同类软件

            AWStats的功能很多,我在此主要用它来分析apache服务器的日志。安装使用之前还是说说大致的工作原理,AWStats提供一系列的perl脚本实现:服务配置,日志读取,报表生成等功能。

            而功能实现的具体执行过程是:首先,当然是apache将访问情况记录到日志中,AWStats每次执行更新时读取这些日志,分析日志数据,将结果存储到数据库中,(这个数据库是AWStats自带的【就是一文本文件】,并不需要第三方软件支持。),最后AWStats提供一个cgi程序通过web页面来显示数据库中所统计的数据。

    AWStats的工作模式是这样的:

    分析日志:运行后将日志统计结果归档到一个AWStats的数据库(纯文本)里;

    输出日志:分两种形式

    • 一种是通过cgi程序读取统计结果数据库输出(Linux中);

    • 一种是运行后台脚本将输出导出成静态文件(Windows中);

    其他同类日志统计分析工具有:

    • AWStats

    • Analog

    • Webalizer

     

     

    三、awstats 安装和配置

    环境信息约定:

    • 日志文件位置:/usr/local/apache/logs

    • 系统:CentOS6.5 X64

    • awstats安装位置:/usr/local/awstats

    • JAWStats安装位置:/htdoc/stats/

    • 这里我们配置的站点域名:www.test.com

    • WEB服务器:Apache 2.2

    • 静态页面文件输出路径:/usr/local/apache/data(可选)

    Requirements:

    To use AWStats, you need the following requirements:

    • Your server must log web access in a log file you can read.

    • You must be able to run perl scripts(.pl files) from command line and / or as CGI(Perl 5.007003 or higher required to run AWStats 6.9 or higher)

    If not, you can solve this by downloading last Perl version at  ActivePerl (Win32) or  Perl.com(Unix/Linux/Other)

    1、安装 perl

    awstats 是由 perl 语言编写的,不管是在Windows还是Linux下,都需要安装perl。所以要首先准备好 perl 环境,通常linux系统都是自带了perl的。

    # perl --version        # 查看是否已经安装了perl, 以及perl 版本号
    # yum -y install perl*  # 如果没有安装,yum install 吧
     

    2、下载 awstats 工具(Last stable version is 7.4),并解压至常规目录 /usr/local

    # wget http://www.awstats.org/files/awstats-7.4.tar.gz
    
    # tar xf awstats-7.4.tar.gz 
    # mv awstats-7.4  /usr/local/awstats
    
    ################ 华丽的分割线 ###############
    # 当然,也可以通过 yum 安装
    # yum -y install awstats
     

    3、安装 awstats

    由于 wget 下来的包文件的权限是非 root用户的,所以需要修改权限,否则稍后 *.pl 无法运行。

    # mkdir /etc/awstats
    # mkdir /var/lib/awstats
    # chown apache:apache /var/lib/awstats
    上面创建的两个目录都将在后面的配置中用到,一个用于存放站点日志分析的配置文件,一个用于存放日志数据信息。
    
    
    接下来执行 /usr/local/awstats/tools下的awstats_configure.pl 配置向导(交互式),用来生成awstats的配置文件,awstats配置文件的命名规则是awstats.WEBSITE.conf。当然这些都是可以在以后的配置文件中修改的。
    # cd  /usr/local/awstats/tools/
    # perl 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
      Found Web server Apache config file '/etc/httpd/httpd.conf'
    # 检测到apache 配置文件
    -----> Check and complete web server config file '/etc/httpd/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.test.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.test.com.conf'
     Config file /etc/awstats/awstats.www.test.com.conf created.
    
    -----> Restart Web server with '/sbin/service httpd restart'
    grep: /etc/httpd/conf/httpd.conf: No such file or directory
    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.test.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... 
    #提示不能自动加入crontab定时任务,需要稍后自己添加,我们按回车继续即可。
    #回头把该命令填入crontab 按指定时间执行
    
    A SIMPLE config file has been created: /etc/awstats/awstats.www.test.com.conf
    You should have a look inside to check and change manually main parameters.
    You can then manually update your statistics for 'www.test.com' with command:
    > perl awstats.pl -update -config=www.test.com
    You can also read your statistics for 'www.test.com' with URL:
    > http://localhost/awstats/awstats.pl?config=www.test.com
    
    Press ENTER to finish...
    #提示配置文件创建完成和如何更新配置及建立静态报告页,这里我们回车即可结束这个配置向导。
    注意:这里要在Awstats安装目录运行。否则会有一些关于标准目录的提示。Awstats缺省标准安装目录是/usr/local/awstats,如果要安装到其它目录需要对awstats_configure.pl进行修改。
     

    Awstats 会自动检测httpd.conf 配置文件,并在其配置文件末尾添加如下语句:

    #
    # Directives to allow use of AWStats as a CGI
    #
    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>
    
    如果是apache 2.4,则需调整: Require all granted
    在这里,允许 /usr/local/awstats/wwwroot 目录定义自己的访问规则,因此我做一些简单的认证。
    
    #
    # This is to permit URL access to scripts/files in AWStats directory.
    #
    <Directory "/usr/local/awstats/wwwroot">
        Options None
        AllowOverride None
        
        AuthType Basic
        AuthName "Restricted Files"
        AuthUserFile /etc/httpd/passwd
        Require user admin
        
        Order allow,deny
        Allow from all
    </Directory>
    
    
    ## 添加apache 认证用户和密码
    # htpasswd -c /etc/httpd/passwd admin
    New password: 
    Re-type new password: 
    Adding password for user admin
    
    ## 重启apache
    # service httpd restart
     

    awstat 目录:

    安装目录: /usr/local/awstats

    配置文件: /etc/awstats

    数据文件: /var/lib/awstats

    3、查看awstats配置文件

            awstats_configure.pl 还将根据安装过程中您的回答(要分析的网站域名)信息,生成配置文件。结束这个向导以后,我们对www.test.com站点的awstats配置文件已经配置好了。下面我们来查看并修改一下这个配置文件。

    接下来,编辑配置文件,AWStats 支持针对多个子域名生成分析日志,主要修改以下几行:

    # cd /etc/awstats/ 
    # ls  
    awstats.www.test.com.conf
    # vim awstats.www.test.com.conf   #这个配置文件有很多配置,我们这里只讲解重点配置。
    
    LogFile="/usr/local/apache/logs/access_%YYYY-24%MM-24%DD-24.log" #日志文件存放路径
    LogType=W                                          #分析web日志
    LogFormat=4                                        #表示日志格式 combined
    DirData="/var/lib/awstats"                         #创建生成的数据路径
    SiteDomain="www.test.com"
    Lang="cn"                                          #默认语言中文
    SkipHosts="127.0.0.1 REGEX[^192.168.]"     #本地及内部的访问不做分析统计
    LevelForWormsDetection=2                     #日志等级,不对警告日志进行统计
     

    LogFile 指明apache的access log所在,这里也可以使用变量,例如:LogFile="/data/log/imysql.cn-access_log.%YY-24%MM-24%DD",具体的请查看 相关文档
    LogFormat 表示日志格式,我在apache的日志格式中,采用 combined,因此这里写成4。如果apache里设置的是 common,则在这里写 2,具体的对应关系可以看 Awstats文档
    SiteDomain 要分析的域名
    DirData 分析结果存放位置(awstas数据库)

    如果apache 进行了日志切割, 这里需要随机应变

    ## awstats
    # vim awstats.www.test.com.conf
    LogFile="/log/www/access_%YYYY-24%MM-24%DD-24.log"   如果进行日志切割,可使用通配符%YYYY-24%MM-24%DD-24 是指年月日模式(昨天)
    %YYYY-0%MM-0%DD-0 (当天)
    
    ## apache
    # vim /etc/httpd/conf/httpd.conf
    #CustomLog logs/access_log combined 
    CustomLog "|/usr/local/sbin/cronolog /log/www/access_%Y%m%d.log" combined
     

    四、awstats 执行日志分析 

        在上面的我们讲解了awstats的yum安装与源码安装,同时配置了一个监控实例,下面我们就执行一下这个监控实例www.test.com

    1、更新awasts数据库

    ## 首先重启一下 httpd 
    # service httpd restart
    
    # perl /usr/local/awstats/tools/awstats_updateall.pl now
    
    上面这种方式是一下子分析所有的域名,也可以像下面这样只分析某个域名:
    # perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=WEBSITE
    
    [root@web ~]# perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.test.com
    Create/Update database for config "/etc/awstats/awstats.www.test.com.conf" by AWStats version 7.4 (build 20150714)
    From data in log file "/var/log/httpd/access_log"...
    Phase 1 : First bypass old records, searching new record...
    Direct access after last parsed record (after line 319)
    Jumped lines in file: 319
     Found 319 already parsed records.
    Parsed lines in file: 5
     Found 0 dropped records,
     Found 0 comments,
     Found 0 blank records,
     Found 0 corrupted records,
     Found 0 old records,
     Found 5 new qualified records.
     

            现在我们需要用awstats来生成对apache日志的统计分析信息。由于我们用的awstats是支持perl的FCGI动态化访问页面,所以此处我们只需要直接更新数据库即可。FCGI程序会自动将数据库以动态页面的形式展现出来,无须再手动生成静态页面了。

    接下来我们来查看一下分析结果

    如果还想通过web server查看分析结果,就需要让web server支持cgi才行了。在这里,我使用apache作为web server,因此我在编译apache时,加上了选项:--enable-cgi

    • LoadModule cgid_module modules/mod_cgid.so

    • 注意cgi脚本的执行权限,一定要apache用户拥有执行权限,否则可能提示Server Internal 错误。

    # chown -R apache:apache /usr/local/awstats
     

    注,如果,你顺利的执行了上面的所有操作。那么OK,现在你已经可以通过访问:http://localhost/awstats/awstats.pl?config=www.test.com ,效果如下图:

    wKioL1X1d_DSOLffAAPA5CWJgzc014.jpg

    cron更新数据库

        由于要得到新的统计信息,就必须更新数据库,也就是说重新做读取日志。分析日志提取里面新增的部分进行分析,将更新的数据存入数据库的过程。最好就让它定时执行。

        最后需要说明的是,在文中已经多次提到过,要能反应最新信息就必须更新数据库。也就是说你可能已经对它进行了多次访问,但是查看统计页面发现没变化。这是因为这些日志还没有更新到数据库.简单的方法就是定时执行。

    00 5 * * * /usr/bin/perl  /usr/local/awstats/tools/awstats_updateall.pl now &> /dev/null
     

    五、awstats 多站点日志分析

    假设我有两个站点:

    配置多站点监控(也就是配置 多个awstats 配置文件即可。分析多个域名的日志,就是把 awstats_configure.pl 多操作几次)

    注,配置 mail.test.com的 配置文件,其实步骤和上面www.test.com一样,只是在域名的地方做更改即可。下面我们就再来演示一下,

    # cd /usr/local/awstats/tools/ 
    # ./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 filesapache groupapacheconfhttpd.conf  
    Config file path ('none' to skip web server setup):
    > /etc/httpd/conf/httpd.conf 
    Your web server config file(s) could not be found. 
    You will need to setup your web server manually to declare AWStats  
    script as a CGI, if you want to build reports dynamically.  
    See AWStats setup documentation (file docs/index.html)
    -----> 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
    -----> 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:  
    > mail.test.com   
    #我们这里配置域名就是mail.test.com,其它地方与www.test.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.test.com.conf' 
    Config file /etc/awstats/awstats.www.test.com.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=mail.test.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... 
    #提示不能自动加入crontab定时任务,需要稍后自己添加,我们按回车继续即可。
    
    A SIMPLE config file has been created: /etc/awstats/awstats.mail.test.com.conf 
    You should have a look inside to check and change manually main parameters.  
    You can then manually update your statistics for 'mail.test.com' with command:  
    > perl awstats.pl -update -config=mail.test.com  
    You can also build static report pages for 'mail.test.com' with command:  
    > perl awstats.pl -output=pagetype -config=mail.test.com
    Press ENTER to finish... 
    
    #提示配置文件创建完成和如何更新配置及建立静态报告页,这里我们回车即可结束这个配置向导。
     

    好了,下面步骤和上面www.test.com配置步骤一样,我这里就不重复说明。

    六、awstats 问题汇总

    1、IP 地址国家、区域显示问题

        Awstats默认安装之后是不具有识别访问者的国家和地区信息的,所以需要安装插件支持Awstats列出访问者的国家和地区,便于分析GeoIP免费的是国家/IP的数据表,GeoIPCityLite是地区的数据表。

    (1).MaxMind目前免费提供了GeoIP 和GeoIPCityLite 数据包:可以定期每个月从以下地址下载

    ## 下载
    # wget  http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
    # wget  http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
    
    ## 解压
    # gzip -d GeoIP.dat.gz 
    # gzip -d GeoLiteCity.dat.gz
    
    ## 移至新建目录 
    # mkdir -pv /var/geoip
    # mv  GeoIP.dat  GeoLiteCity.dat GeoIPASNum.dat /var/geoip/
    
    ## 安装源
    # wget http://ftp.sjtu.edu.cn/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
    # rpm -ivh epel-release-6-8.noarch.rpm
    warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
    Preparing...             ########################################### [100%]
    1:epel-release           ########################################### [100%]
    
    # yum clean all
    # yum makecache
    
    ## 安装GeoIP C库与 GeoIP perl库
    # yum  -y  install  GeoIP  perl-Geo-IP
    
    ## 修改 awstats 配置文件
    # vim /etc/awstats/awstats.www.test.com.conf
    
    #1444 行左右添加:
    LoadPlugin="geoip GEOIP_STANDARD /var/geoip/GeoIP.dat"
     
    #1464 行左右添加: 
    LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /var/geoip/GeoLiteCity.dat"
    
    
    ## 删除旧的统计数据
    # rm -rf /var/lib/awstats/*
    
    ## 重新生成数据库
    # perl /usr/local/awstats/tools/awstats_updateall.pl now
    # perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.test.com
    
    # 生成 html 页面
    # /usr/local/awstats/tools/awstats_buildstaticpages.pl -update  -config=www.test.com -lang=cn
     

    2、中文乱码问题

        Awstats是一套非常好用的免费的日志分析软件,他是用perl实现的,支持web log、ftp log和mail log;而且它还能自动根据你浏览器的字符设置来选取语言(支持中文)。但是缺省安装的话有个问题,就是用来搜索的关键字如果是中文的话显示出来是乱码的。 之所以搜索的关键字句会变成乱码的原因,主要是因为现在的搜索引擎都是使用UTF8,而Awstats是使用decodeUTFkeys这个plugin来处理搜索引擎的UTF8关键字,默认是没有打开的,所以在显示上会出现乱码。要解决中文乱码问题,方法也很简单,

    在配置文件中把decodeutfkeys这个plugin打开就可以了。在配置文件中找到:

    #LoadPlugin="decodeutfkeys"

    去掉前面的#就可以了。

    # vim /etc/awstats/awstats.www.test.com.conf
    #LoadPlugin="decodeutfkeys"             #1300 行
    LoadPlugin="decodeutfkeys"
     

    这样我们的中文显示就完成了,但是打开LoadPlugin="decodeutfkeys"这个插件在一些机器上会报错,下面我们来演示一下报错的情况。

    报错

    从上面的报错可以看出这是缺少 Perl 的 URI:Escape模块,下面我们解决一下这个问题:

    # wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/URI-1.60.tar.gz
    # tar xf URI-1.60.tar.gz
    # cd URI-1.60
    # perl Makefile.PL
    # make && make install
     

    七、awstats 总结

        AWStats是在Sourceforge上发展很快的一个基于Perl的WEB日志分析工具。相对于另外一个非常优秀的开放源代码的日志分析工具Webalizer,AWStats的优势在于:

    1.界面友好:可以根据浏览器直接调用相应语言界面(有简体中文版)

    2.基于Perl:并且很好的解决了跨平台问题,系统本身可以运行在GNU/Linux上或Windows上(安装了ActivePerl后);分析的日志直接支持Apache格式 (combined)和IIS格式(需要修改)。Webalizer虽然也有Windows平台版,但目前已经缺乏 维护;AWStats完全可以实现用一套系统完成对自身站点不同WEB服务器:GNU/Linux/Apache和Windows/IIS服务器的统一统计。

    3.效率比较高:AWStats输出统计项目比Webalizer丰富了很多,速度仍可以达到Webalizer的1/3左右,对于一个日访问量 百万级的站点,这个速度都是足够的;

    4.配置/定制方便:系统提供了足够灵活但缺省也很合理的配置规则,需要修改的缺省配置不超过3,4项就可以开始运行,而且修改和扩展的插件还是 比较多的;

    5.AWStats的设计者是面向精确的"Human visits"设计的,因此很多搜索引擎的机器人访问都被过滤掉了,因此有可能比其他日志统计工具统计的数字要低,来自公司内部的访问也可以通过IP过滤 设置过滤掉。

    6.提供了很多扩展的参数统计功能:使用ExtraXXXX系列配置生成针对具体应用的参数分析会对产品分析非常有用。

    AWStats 是一个免费的强大而有个性的工具,带来先进的网络,流量,FTP或邮件服务器统计图. 本日志分析器作为CGI或从命令行在数个图形网页中显示你日志中包含的所有可能信息. 它利用一部分档案资料就能经常很快地处理大量日志档案, 它能分析日志文件来自从各大服务器工具 ,如 Apache日志档案 s (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C的日志格式)及许多其他网站,Proxy(代理服务器)、Wap、流量服务器、邮件服务器和一些 FTP服务器。

    看一看这个比较表在最著名统计工具 (AWStats, Analog, Webalizer,...)之间有何特点和不同的想法。AWStats 是一个在GNU通用公共许可证下发行的免费软件. 你可以看看这个许可证图表而知道你可以/不可以做。由于AWStats工程来自网上信息,但也作为CGI、 它可以与允许进入Perl、CGI与日志的大型网站主办提供商一起工作。

    八、安装配置 JAWStats 

    JAWStats 是基于 Awstats 统计数据的,但其界面更为强悍,有了JAWStats 你甚至可以抛弃第三方统计了。 
    
    2.1. 下载与安装 
    # wget http://static.jawstats.com/src/jawstats-0.7beta.tar.gz
    # mkdir /var/www/stats/ 
    # tar -zxf jawstats-0.7beta.tar.gz -C /var/www/stats/ 
    # cd /var/www/stats/ 
    # cp config.dist.php config.php 
     
    2.2. 修改配置文件 
    官方配置说明见:http://www.jawstats.com/documentation 
    jawstats 是支持多站点的,每个 $aConfig 对应一个站点,并可以自由切换 
    <?php 
      // core config parameters 
      $sDefaultLanguage      = "zh-cn"; // 设置默认语言 
      $sConfigDefaultView    = "thismonth.all"; 
      $bConfigChangeSites    = false; //是否可以更换站点 
      $bConfigUpdateSites    = false; //是否可以更新统计数据 
      $sUpdateSiteFilename   = "xml_update.php"; 
      
      // individual site configuration 
      $aConfig["www.zzxtbl.com"] = array( // site1 网站域名(注意不能乱填) 
        "statspath"   => "/var/lib/awstats/", //awstats 统计数据目录 
        "updatepath"  => "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl/", //用于更新统计数据 
        "siteurl"     => "http://www.zzxtbl.com", //点击首页标题后会前往这个地址 
        "sitename"    => "test.org", //首页标题 
        "theme"       => "default", 
        "fadespeed"   => 250, 
        "password"    => "my-1st-password", //更新统计数据需要输入这个密码 
        "includes"    => "", 
        "language"    => "zh-cn" 
      ); 
    ?> 
     
    
     <?php
    
      // core config parameters
      $sDefaultLanguage      = "zh-cn";
      $sConfigDefaultView    = "thismonth.all";
      $bConfigChangeSites    = false;
      $bConfigUpdateSites    = false;
      $sUpdateSiteFilename   = "xml_update.php";
    
      // individual site configuration
      $aConfig["site1"] = array(
        "statspath"   => "/var/lib/awstats/",
        "updatepath"  => "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl/",
        "siteurl"     => "http://www.zzxtbl.com",
        "theme"       => "default",
        "fadespeed"   => 250,
        "password"    => "my-1st-password",
        "includes"    => ""
      );
    
    ?>
    
    2.3. 安装中文语言包 
     
    首先下载 jawstats 多国语言包,解压缩后上传替换 lang 目录。 
    wget http://www.jawstats.com/src/languagepack.zip 
     
    需要注意的是,你要修改 translations.php 文件的编码为UTF-8,不然全乱码了。 
    另外修改汉化文件,也是translations.php,不能只修改zh-cn.js文件。 
    
    
    2.4.在http服务器的httpd.conf添加虚拟目录
    Alias /zzxtbl "/usr/local/jawstats"
    <Directory "/usr/local/jawstats">
        Options Indexes MultiViews
        Order allow,deny
        Allow from all
    </Directory>
     

    http://www.cnblogs.com/fnng/archive/2012/08/31/2666175.html

    http://freeloda.blog.51cto.com/2033581/1346412

    http://blog.fity.cn/post/389/

    http://zzxtbl.blog.51cto.com/7620672/1650825

    九、Windows 平台安装 awstats 

    1、安装环境

    • windows Server 2008 R2

    • apache 2.2

    • awstats版本为7.3

    Windows系统下配置 apache 日志切割方法:

    A、使用 cronolog 日志轮转工具

    从 http://cronolog.org/download/  可以下载 cronolog程序, 把下载的 cronolog程序放到 apache 的bin 目录下(详细参数参加: http://cronolog.org/usage.html)

    wKioL1X24nDSIdMOAAFUTs0ku_o306.jpg

    B、使用 rotatelogs 程序

    rotatelogs 是 apache 自带的管道日志程序,参数如下(参考:http://lamp.linux.gov.cn/Apache/ApacheMenu/programs/rotatelogs.html )

    wKiom1X24D2CzlWqAAHhStGyHRY612.jpg

    二、安装备忘

    1、注意:由于awstats依赖于perl,所以提前安装perl环境

    下载perl:   http://www.activestate.com/activeperl/downloads

    或者直接在百度搜索下载: activeperl 

    根据自己的环境选择不同的安装包,通常下载 ActivePerl_5.x.msi 可执行程序,然后安装

    1、测试是否加入环境变量
    C:UsersAdministrator> perl -v
    
    2、根据安装提示
    记录perl的路径(如X:perlinperl.exe),下面会用到
    
    3、可能存在的问题
    perl自动安装的情况会将路径配置到%system%之前,导致系统无法识别,解决方法就是把路径放置到PATH最后
     

    2、配置 apache 支持 perl (CGI)

    修改httpd.conf文件:
    #ScriptAlias /cgi-bin/  "c:/Apache/cgi-bin/"
    将前面的 # 号去掉,改为
    ScriptAlias /cgi-bin/  "c:/Apache/cgi-bin/"
    
    AddHandler cgi-script .cgi 
    在后面加上一个空格和 .pl , 改为
    AddHandler cgi-script .cgi .pl
    
    #LoadModule alias_module modules/mod_alias.so
    启用alias_module模块,把前面的#号去掉,改为 
    LoadModule alias_module modules/mod_alias.so
    
    修改后记得重启apache
     

    3、解压AWStats

    下载AWStats(国内环境的话,需要自带工具)

    http://sourceforge.net/projects/awstats

    自行选择需要解压的路径

    4、设置配置文件

    定位到awstats-7.3 ools下,执行 awstats_configure 文件,这个文件的主要功能就是设置WEB容器的路径,log路径等。

    配置完后,APACHE的 httpd.conf 下会生成类似一下的内容

    #
    # Directives to allow use of AWStats as a CGI
    #
    Alias /awstatsclasses "c:/awstats-7.3/wwwroot/classes/"
    Alias /awstatscss "c:/awstats-7.3/wwwroot/css/"
    Alias /awstatsicons "c:/awstats-7.3/wwwroot/icon/"
    ScriptAlias /awstats/ "c:/awstats-7.3/wwwroot/cgi-bin/"
    #
    # This is to permit URL access to scripts/files in AWStats directory.
    #
    <Directory "c:/awstats-7.3/wwwroot">
    Options none
    AllowOverride none
    Order allow,deny
    Allow from all
    </Directory>
     

    同时在awstats-7.3wwwrootcgi-bin文件夹下会生成一个 awstats.domain.com.conf 文件

    4、修改配置文件

    定位到awstats-x.xwwwrootcgi-bin下,打开awstats.domain.com.conf文件
    修改如下内容
    
    LogFile="C:/Apache2.2/logs/fs_access-%YYYY-24%MM-24%DD-24.log"        
    #日志文件存放路径,要与你的apache的log路径一致
    
    LogFormat=4
    SiteDomain="fs.zhubajie.la"
    Lang="cn"                      #默认语言中文
    SkipHosts="127.0.0.1"          #本地访问不做分析统计
     

    5、生成数据

    cmd 定位到awstats文件下(awstats-x.xwwwrootcgi-bin),在cmd中执行以下命令
    
    注意:请将domain.com替换为你的域名或地址
    # perl.exe awstats.pl -update -config=domain.com
    正常情况下会显示
    不出意外的话,会显示出如下信息:
    C:awstats-7.3wwwrootcgi-bin>perl.exe awstats.pl -update -config=fs.zhubajie.l
    a
    Create/Update database for config "./awstats.fs.zhubajie.la.conf" by AWStats ver
    sion 7.3 (build 20140126)
    From data in log file "C:/Apache2.2/logs/fs_access-20150914.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: 134025
     Found 0 dropped records,
     Found 0 comments,
     Found 0 blank records,
     Found 0 corrupted records,
     Found 0 old records,
     Found 134025 new qualified records.
    
     
     同时在awstats-x.xwwwrootcgi-bin下会生成一个类似awstats0X2013.domain.txt 的文件
     

    6、修改awstats文件

    编辑: awstats-x.xwwwrootcgi-binawstats.pl
    
    由于win下路径与linux中不同,所以这个文件第一行应该改成 #!X:/perl/bin/perl.exe (该地址为前期你安装的perl的地址)
    
    否则后期运行会出错
    couldn’t create child process: 720002: awstats.pl
     

    7、浏览器打开

    在浏览器中输入类似的地址 http://localhsot/awstats/awstats.pl?config=domain.com,正常情况下即可看到结果

    高级配置

    1、增加一个显示来访IP归属地的功能

    执行如下命令

    ppm install Geo::IP::PurePerl
    ppm install Geography::Countries
    ppm install IP::Country
    ppm install Geo-IPfree
    ppm install Net-Xwhois

    安装GeoIP

    http://dev.maxmind.com/geoip/legacy/geolite/

    修改awstats.domain.com.conf文件,找到如下内容

    # 开启 GeoIP 反查模块
    LoadPlugin="geoip GEOIP_STANDARD D:/awstats/awstats-x.x/wwwroot/cgi-bin/ipdata/GeoIP.dat"
    # 开启 IP 反查的外挂
    LoadPlugin="geoipfree"
    # 开启 decodeutfkeys 外挂,解决”用以搜索的关键词”乱码
    LoadPlugin="decodeutfkeys"

    更新配置文件

    perl.exe awstats.pl -config=domain.com -update

    2、定期更新

    通过win的计划任务搞定

    编辑一个 bat 批处理文件, 内容如下:
    
    C:Perlinperl.exe  C:awstats-7.3wwwrootcgi-binawstats.pl -update -config=fs.zhubajie.la
     

    3、加一个需要用户名才可以访问的功能

    由于要求在内网访问,所以没有涉及

    参考阅读:

    http://luestudy.blog.51cto.com/8480481/1395362

    http://blog.chinaunix.net/uid-7354272-id-2643593.html

    怎样在windows下安装Perl

    http://jingyan.baidu.com/article/380abd0aa6c7371d90192c1b.html

    awstats 分析 nginx 日志

    1、安装nginx 以及 awstats 的过程就不讲解了, 可以参考上面的内容。

    2、本文主要介绍通过让 awstats 对日志统计的结果生成静态页面,然后通过 Nginx 输出以达到统计 Nginx 访问日志的效果,其中还包括如何让 Nginx 自动切割日志文件。对于nginx的日志,我的做法是按天切割。

    配置 Nginx 自动切割日志

    跟 Apache HTTP Server(以下称 Apache)不同的是,Apache 可以将日志输出通过管道的方式进行重新定向,依此来进行自动的日志切割。Nginx 在现今版本上还没能跟 Apache 一样,通过%YY等参数按日期分批创建日志,但是通过给 nginx 进程发送一个特定的信号,可以使 nginx 重新生成日志文件。我们可以定期执行一个 Shell 脚本来切换日志,重新命名或转移,具体的脚本如下:

    # mv  /usr/local/nginx/logs/access.log  /usr/local/nginx/logs/access_`date -d "yesterday" +%Y%m%d`.log
    # killall –s USR1 nginx	#使用USR1参数通知Nginx进程切换日志文件
     

    将以上脚本内容保存为文件名为 logcron.sh 存到自定的目录中,例如 /opt/nginx/sbin/logcron.sh

    使用 Crontab 让该脚本程序在每天晚上 11 点 59 分自动执行,即可做到按天创建日志。

    需要注意的是,nginx的日志应该遵循以下格式,才可以被awstats识别,如定义日志格式

    # 定义日志格式
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
                      
    # 使用日志格式
    access_log  /home/www/logs/access.log  main;
    
    # nginx 日志进行了切割
    mv ${logs_path}/access.log  ${logs_path}/access_$(date -d "yesterday" +"%Y%m%d").log
    
    生成的日志格式: access_20150912.log
     

    执行 tools 目录中的 awstats_configure.pl 配置向导,创建一个新的统计。

    [root@iredmail tools]# ./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 filesapache groupapacheconfhttpd.conf
    Config file path ('none' to skip web server setup):
    > none  #这里填none并回车,因为我们没有使用apache,我们这里用的是 Nginx,所以跳过。
    
    Your web server config file(s) could not be found.
    You will need to setup your web server manually to declare AWStats
    script as a CGI, if you want to build reports dynamically.
    See AWStats setup documentation (file docs/index.html)
    
    -----> 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:
    > slog.fity.cn   #统计网站的域名,例如slog.fity.cn
    
    -----> 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.slog.fity.cn.conf'
    Config file /etc/awstats/awstats.slog.fity.cn.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=slog.fity.cn  #回头把该命令填入crontab 按指定时间执行
    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.slog.fity.cn.conf  #新配置文件所在的路径
    You should have a look inside to check and change manually main parameters.
    You can then manually update your statistics for 'slog.fity.cn' with command:
    > perl awstats.pl -update -config=slog.fity.cn
    You can also build static report pages for 'slog.fity.cn' with command:
    > perl awstats.pl -output=pagetype -config=slog.fity.cn
    
    Press ENTER to finish...   #回车完成配置文件的创建
     

    以上步骤默认会产生配置文件 ==>> /etc/awstats/awstats.slog.fity.cn.conf

    awstats 配置文件的命名规则:awstats.website.conf

    修改配置文件

    # vi /etc/awstats/awstats.slog.fity.cn.conf
    
    (1)指定日志文件路径(非常重要,必须的一个步骤)
    LogFile="/usr/local/nginx/logs/access.log"(51行左右) //指定log文件的存储位置
    
    如果你希望每天能定时生成昨天的报表,可以:
    LogFile="/usr/local/nginx/logs/access_%YYYY-24%MM-24%DD-24.log"   // 日志切割后
    注:根据你的日志路径和对应的日志文件名进行修改。对应Nginx日志切割程序所生成的目录存放结构保存的nginx日志文件。要注意Awstats的年月日格式的跟Nginx的写法有所不同,其中%YYYY-24 、 %MM-24、%DD-24表示年月日都减去24小时,也就是昨天的日志目录。
    
    
    
    ############# 可选 ##################
    (2)修改Nginx日志格式              ## 这一步感觉非必须 ## 
    这里Awstats执行统计的顺序是:
    Nginx产生日志–>日志切割–>Nginx继续产生日志–>另存切割日志–>交由Awstats统计–>生成结果
    
    修改日志格式,由于这里nginx生成日志格式要与awstats所需要的匹配,所以要修改日志格式,以便awstats读取。注释掉LogFormat=1,添加如下,每一个变量的参数,配置文件上方有解释,这里不多说
    
    ## 编辑 awstats 配置文件
    #LogFormat=1
    LogFormat="%host %other %other %time1 %other %methodurl %code %bytesd %refererquot %uaquot"
    
    ## 修改Nginx日志格式:
    nginx的日志应该遵循以下格式,才可以被awstats识别。这里的main是指格式代称,如果有多个虚拟主机,代称不能一样
                    
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status  $body_bytes_sent  "$http_referer" '
                      '"$http_user_agent"  "$http_x_forwarded_for"';                  
    使用日志格式
    access_log  /usr/local/nginx/logs/access.log  main;
    
    补充说明:把log_format这段代码放在你nginx的http的定义段中,可以在下面的每一个server中引用此格式。不必在每个server里面都去定义格式。
    
    (3)修改SiteDomain=slog.fity.cn 网站域名
    
    (4)修改LoadPlugin="decodeutfkeys",去掉注视,否则会出现中文乱码
    
    (5)修改Lang="cn"语言为中文
    
    (6)添加LIMITFLUSH=5000000尽量大,可根据情况而定。增大AWStats的$LIMITFLUSH,减少磁盘临时文件读写 Flush history file on disk (unique url reach flush limit of 5000)
    ############# 可选 ##################
    
    
    运行awstats的wwwroot目录中的awatsts.pl来测试一下
    # /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=slog.fity.cn
    
    如果看到类似下面的提示,就说明配置文件都正确了
    From data in log file "/usr/local/nginx/logs/access_20150914.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: 95
     Found 0 dropped records,
     Found 0 comments,
     Found 0 blank records,
     Found 0 corrupted records,
     Found 0 old records,
     Found 95 new qualified records.
     
    
    看到以上显示,证明日志切割和 Awstats 都已经运行无误了。统计分析完成后,结果还在 Awstats 的数据库中。在 Apache 上,可以直接打开 Perl 程序的网页查看统计。 但本文开始时已经提到,Nginx 对 Perl 支持并不好,所以我们要换个方法,利用 awstats 的工具将统计的结果生成静态文件,具体的步骤如下:
    1、首先在 webroot 目录下创建一个文件夹。例:/usr/local/nginx/html/awstats
    # mkdir /usr/local/nginx/html/awstats
    
    2、写一个脚本,定期执行让 Awstats 把静态页面生成到该目录中 
    #!/bin/bash 
    
    /usr/local/awstats/tools/awstats_buildstaticpages.pl -update   
    -config=slog.fity.cn -lang=cn -dir=/usr/local/nginx/html/awstats 
    -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl
    
    ## 加上可执行权限,并测试
    # chmod +x /root/awstats.sh 
    # /root/awstats.sh
    
    ## 加入 crontab 
    00 1 * * * /root/awstats.sh
    
    上述命令的具体意思如下:
    § /usr/local/awstats/tools/awstats_buildstaticpages.pl      Awstats 静态页面生成工具 
    § -update -config=slog.fity.cn                 更新配置项 
    § -lang=cn                           语言为中文 
    § -dir=/usr/local/nginx/html/awstats              统计结果输出目录 
    § -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl         Awstats 日志更新程序路径。 
    
    3、然后在你的nginx的配置文件中,在你想要安置awstats或默认的ip或域名的server段中,加入关于awstats和icon的两个目录配置。
    
    server {
    	listen       80;
    	server_name  localhost;
    
    	location ~ ^/awstats/ {         # awstats  静态页面目录
    		root   /usr/local/nginx/html;    
    		# 靠, 不是 /usr/local/nginx/html/awstats 坑了好久
    		autoindex on;         #可以目录浏览你的多个域名的目录用于分析
    		index  index.html;
    		access_log off;
    		error_log off;
    	}
    
    	location ~ ^/icon/ {             # 图标目录
    		root   /usr/local/awstats/wwwroot;
    		index  index.html;
    		access_log off;
    		error_log off;
    	}
    }
     

    用浏览器查看到统计的详细结果  http://youhostname/awstats/awstats.www.slog.fity.cn.html

    至此,使用 awstats 已能完全支持 Nginx 的日志统计。

    认证访问

    一般站长都不愿随便让人知道自己站的真实流量,所以要把 Awstats 统计结果页面进行密码保护。Nginx 使用的是跟 Apache 一样的密码加密格式,这里需要用到 apache 自带的工具 htpasswd。

    如果你在本机上默认装有 Apache,这你就只需在它的程序目录下运行

    # /usr/bin/htpasswd -c /usr/local/nginx/passwd  admin          #用户名为admin
    
    New password:            输入密码
    Re-type new password:        重复输入
    Adding password for user admin    创建成功
    
    
    修改 nginx.conf 在 location 中加入(加粗部分):
    
    server {
        listen       80;
        server_name  localhost;
    
        location ~ ^/awstats/ {         # awstats  静态页面目录
            root   /usr/local/nginx/html;    
            # 靠, 不是 /usr/local/nginx/html/awstats 坑了好久
            autoindex on;         #可以目录浏览你的多个域名的目录用于分析
            index  index.html;
            access_log off;
            error_log off;
            auth_basic "secret";                             #虚拟主机认证命名 
                    auth_basic_user_file  /usr/local/nginx/passwd.db; #虚拟主机用户名密码认证数据库 
              
        }
    
        location ~ ^/icon/ {             # 图标目录
            root   /usr/local/awstats/wwwroot;
            index  index.html;
            access_log off;
            error_log off;
        }
    }
    
    然后,重新启动一下 nginx
     

    如果你想给你的awstats加上访问密码,可以见这里:nginx为目录或网站加上密码认证

    问题汇总

    当再次输入网址时,在页面上只出现了一行字:
    Content-type: text/html; charset=gb2312 Cache-Control: public Last-Modified: Sat Feb 11 13:14:37 2016 Expires: Sat Feb 11 13:14:37 2016 

    如果出现,是因为浏览器不支持frame(似乎是服务器端问题),请在页面上右键选择查看源文件,有这样一行字:Your browser does not support frames.You must set AWStats UseFramesWhenCGI parameter to 0 to see your reports.
    好,现在去修改awstats.conf 配置文件,把UseFramesWhenCGI参数设成0。

    http://www.ibm.com/developerworks/cn/linux/l-cn-awstats-nginx/

    http://blog.sina.com.cn/s/blog_8db76d6d0101342m.html

    http://lodar.net/methods-of-apache-web-log-daily-rotation/

    http://www.linuxde.net/2013/06/14027.html

    http://www.cnblogs.com/cocowool/archive/2010/09/07/1820626.html

    http://www.cnblogs.com/cocowool/archive/2010/09/10/1823504.html

  • 相关阅读:
    Visual Studio 和 c# 正则表达式
    程序员DD 《Spring boot教程系列》补充
    c# 多线程编程中AutoResetEvent和ManualResetEvent
    c# 事件和EventManager
    卸载重装Mysql
    c# 语法要点速览
    在高分屏正确显示CHM文件
    ss user-rule自定义规则并硬连接到OneDrive进行自动同步
    利用webmagic获取天猫评论
    使用Selenium对新浪微博模拟登录
  • 原文地址:https://www.cnblogs.com/xiaowenshu/p/10315135.html
Copyright © 2011-2022 走看看