日历

2017年十二月
« 9月    
 123
45678910
11121314151617
18192021222324
25262728293031

最近评论

    linux企业应用

    linux下安装awstats7.0

        免费的网页日志分析工具awstats,可以分析统计站点的一下信息:
        一:访问量,访问次数,页面浏览量,点击数,数据流量等   
        二:精确到每月、每日、每小时的数据   
        三:访问者国家   
        四:访问者IP   
        五:Robots/Spiders的统计   
        六:纺客持续时间   
        七:对不同Files type 的统计信息   
        八:Pages-URL的统计   
        九:访客操作系统浏览器等信息   
        十:其它信息(搜索关键字等等)
    awstats最新版本下载地址:http://cdnetworks-kr-1.dl.sourceforge.net/project/awstats/AWStats/7.0/awstats-7.0.tar.gz

    1、下载后,进行加压安装
    [root@myfreelinux pub]# ls
    awstats-7.0.tar.gz
    [root@myfreelinux pub]# tar zxf awstats-7.0.tar.gz
    [root@myfreelinux pub]# mv awstats-7.0 /usr/local/awstats  #移动到/usr/local目录下,或者直接解压的时候解压到/usr/local目录下

    2、[root@myfreelinux pub]# vi /usr/local/apache2/conf/httpd.conf 在httpd.conf中添加基于域名的虚拟机
    NameVirtualHost 192.168.1.6
    <VirtualHost 192.168.1.6>
            DocumentRoot htdocs/www
            ServerName   www.myfreelinux.com
            ErrorLog     logs/www/error_log
            CustomLog    logs/www/access_log combined
    </VirtualHost>
    [root@myfreelinux pub]# /usr/local/apache2/bin/apachectl restart    #添加完虚拟主机后需要重新启动apache服务

    3、安装awstats
    [root@myfreelinux tools]# pwd
    /usr/local/awstats/tools
    [root@myfreelinux 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
      Found Web server Apache config file ‘/usr/local/apache2/conf/httpd.conf’

    —–> Check and complete web server config file ‘/usr/local/apache2/conf/httpd.conf’
      All AWStats directives are already present.

    —–> 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.myfreelinux.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):
    >

    —–> Create config file ‘/etc/awstats/awstats.www.myfreelinux.com.conf’
     Config file /etc/awstats/awstats.www.myfreelinux.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=www.myfreelinux.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.myfreelinux.com.conf
    You should have a look inside to check and change manually main parameters.
    You can then manually update your statistics for ‘www.myfreelinux.com’ with command:
    > perl awstats.pl -update -config=www.myfreelinux.com
    You can also read your statistics for ‘www.myfreelinux.com’ with URL:
    > http://localhost/awstats/awstats.pl?config=www.myfreelinux.com

    Press ENTER to finish…

    安装完成后,重新启动apache服务
    [root@myfreelinux tools]# /usr/local/apache2/bin/apachectl restart

    4、配置awstats文件
    [root@myfreelinux tools]# vi /etc/awstats/awstats.www.myfreelinux.com.conf
    4.1首先修改日志文件的位置:
    LogFile=”/var/log/httpd/mylog.log” 修改为
    LogFile=”/usr/local/apache2/logs/www/access_log”
    4.2再修改服务日志类型为:
    LogType=W  w表示为WEB日志
    4.3然后设置日志格式:
    LogFormat=1  1表示采用NCSA apache combined/ELF/XLF log format
    4.4然后设置要分析的网站域名:
    SiteDomain=www.myfreelinux.com”
    HostAliases=”myfreelinux.com www.myfreelinux.com 127.0.0.1 localhost”
    4.5修改awstats数据存放位置
    DirData=”/var/lib/awstats” 修改为 DirData=”/usr/local/awstats/data”
    4.6设置DirCgi
    DirCgi=”/awstats” 修改为:DirCgi=”/usr/local/awstats/wwwroot/cgi-bin”
    4.7设置DirIcons
    DirIcons=”/awstatsicons”修改为:DirIcons=”/usr/local/awstats/wwwroot/icon”
    4.8设置AllowToUpdateStatsFromBrowser=1,这样在浏览器上点击”Update now”可以更新统计结果

    5、修改awstats的权限
    [root@myfreelinux local]# pwd
    /usr/local
    [root@myfreelinux local]# chown -R root:root awstats
    [root@myfreelinux local]# chmod -R 755 awstats
    [root@myfreelinux local]# ls -ld awstats/
    drwxr-xr-x 5 root root 4096 Jun 23 05:55 awstats/
    [root@myfreelinux local]# mkdir awstats/data
    [root@myfreelinux local]# cd awstats
    [root@myfreelinux awstats]# chown nobody data
    [root@myfreelinux awstats]# chown 755 data
    接下来要创建awstats初始化数据库
    [root@myfreelinux cgi-bin]# pwd
    /usr/local/awstats/wwwroot/cgi-bin
    [root@myfreelinux cgi-bin]# perl awstats.pl -config=www.myfreelinux.com -update -lang=cn
    Create/Update database for config “/etc/awstats/awstats.www.myfreelinux.com.conf” by AWStats version 7.0 (build 1.964)
    From data in log file “/usr/local/apache2/logs/www/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: 153
     Found 0 dropped records,
     Found 0 comments,
     Found 0 blank records,
     Found 41 corrupted records,
     Found 0 old records,
     Found 112 new qualified records.
    创建awstats初始化静态统计页面
    [root@myfreelinux cgi-bin]# perl awstats.pl -config=www.myfreelinux.com -output -staticlinks -lang=cn>awstats.www.myfreelinux.com.html
    [root@myfreelinux cgi-bin]# chmod 755 /usr/local/awstats/wwwroot/cgi-bin/*.pl #设置cgi-bin下的*.pl具有可执行权限

    6、设置完成后,进行测试。在firefox地址栏中输入:
    http://www.myfreelinux.com/awstats/awstats.pl?config=www.myfreelinux.com

    7、过个站点的日志统计
        比如再添加feed.myfreelinux.com站点的统计,步骤如下:
    [root@myfreelinux apache2]# vi conf/httpd.conf    #添加如下内容
    <VirtualHost 192.168.1.6>
            DocumentRoot htdocs/feed
            ServerName   feed.myfreelinux.com
            ErrorLog     logs/feed/error_log
            CustomLog    logs/feed/access_log combined
    </VirtualHost>
    [root@myfreelinux apache2]# mkdir logs/feed
    [root@myfreelinux apache2]# mkdir htdocs/feed
    [root@myfreelinux apache2]# bin/apachectl restart
    然后修改awstats配置文件的内容
    [root@myfreelinux awstats]# cp awstats.www.myfreelinux.com.conf awstats.feed.myfreelinux.com.conf
    [root@myfreelinux awstats]# vi awstats.feed.myfreelinux.com.conf #主要修改内容如下:
    LogFile=”/usr/local/apache2/logs/feed/access_log”
    SiteDomain=”feed.myfreelinux.com”
    HostAliases=”myfreelinux.com feed.myfreelinux.com 127.0.0.1 localhost”

    [root@myfreelinux cgi-bin]# pwd
    /usr/local/awstats/wwwroot/cgi-bin
    [root@myfreelinux cgi-bin]# perl awstats.pl -config=feed.myfreelinux.com -update -lang=cn  #创建awstats初始化数据库
    [root@myfreelinux cgi-bin]#perl awstats.pl -config=cs.waytek.cn -output -staticlinks -lang=cn>awstats.cs.waytek.cn.html #创建awstats初始化静态统计页面
    DNS域名也要添加上feed.myfreelinux.com,
    [root@myfreelinux named]# cat myfreelinux.com.zone
    $TTL 86400
    @ IN SOA myfreelinux.com. root.myfreelinux.com.(20100704 10M 3H 3D 1D)
    @ IN NS www.myfreelinux.com.
    @ IN NS feed.myfreelinux.com.
    www IN A 192.168.1.6
    feed IN A 192.168.1.6
    [root@myfreelinux named]# cat 192.168.1.arpa
    $TTL 86400
    @ IN SOA myfreelinux.com. root.myfreelinux.com.(20100704 20M 3H 12H 1D)
    @ IN NS www.myfreelinux.com.
    @ IN NS feed.myfreelinux.com.

    6 IN PTR www.myfreelinux.com.
    6 IN PTR feed.myfreelinux.com.

    8、测试http://feed.myfreelinux.com/awstats/awstats.pl?config=feed.myfreelinux.com,结果:

    安装Geo-IP可参考:http://bbs.linuxpk.com/viewthread.php?tid=9149http://blog.csdn.net/ronaldchan2005/archive/2007/03/10/1526054.aspx

    9、安装GEO-IP
    GeoIP和Geo:IPfree都是免费的,是国家/IP的影射表,通过DNS反相解析域名得到的统计准确,速度非常快。GeoIP的API和默认的库是免费的,但数据更新服务收费。Geo::IPfree代码是公开的,数据库也是公开的,因此可以自己建立自己的数据库。
    Geo-IP-PurePerl-1.25下载地址:http://geolite.maxmind.com/download/geoip/api/pureperl/
    下面是安装步骤:
    [root@myfreelinux pub]# tar zxvf Geo-IP-PurePerl-1.25.tar.gz
    [root@myfreelinux pub]# mv Geo-IP-PurePerl-1.25 /usr/local/awstats/Geo-IP-PurePerl
    [root@myfreelinux pub]# cd /usr/local/awstats/Geo-IP-PurePerl/
    [root@myfreelinux Geo-IP-PurePerl]# perl Makefile.PL
    Checking if your kit is complete…
    Looks good
    Writing Makefile for Geo::IP::PurePerl
    [root@myfreelinux Geo-IP-PurePerl]# make
    [root@myfreelinux Geo-IP-PurePerl]# make install

    修改awstats文件:
    [root@myfreelinux Geo-IP-PurePerl]# vi /etc/awstats/awstats.www.myfreelinux.com.conf
    [root@myfreelinux Geo-IP-PurePerl]# vi /etc/awstats/awstats.feed.myfreelinux.com.conf
    #LoadPlugin=”decodeutfkeys”
    #LoadPlugin=”geoip GEOIP_STANDARD /pathto/GeoIP.dat”
    找到这两行,并将注销“#”删除,其中这个插件。

    http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/,下载GeoIP.dat.gz
    [root@myfreelinux awstats]# cp /var/ftp/pub/GeoIP.dat.gz .
    [root@myfreelinux awstats]# gzip -d GeoIP.dat.gz
    [root@myfreelinux awstats]# chmod 755 -R GeoIP.dat Geo-IP-PurePerl/
    [root@myfreelinux awstats]# chown -R root:root GeoIP.dat Geo-IP-PurePerl/

    安装Geo-IP可参考:http://bbs.linuxpk.com/viewthread.php?tid=9149http://blog.csdn.net/ronaldchan2005/archive/2007/03/10/1526054.aspx,在这里没有安装完成,不做了!:lol:

    评论已关闭。