http日誌分析工具awstat安裝詳解
http日誌分析工具awstat安裝詳解
awstat的功能:
AWStats是在Sourceforge上發展很快的一個基於Perl的WEB日誌分析工具。它可以統計您站點的如下信息:
一:訪問量,訪問次數,頁面瀏覽量,點擊數,數據流量等
二:精確到每月、每日、每小時的數據
三:訪問者國家
四:訪問者IP
五:Robots/Spiders的統計
六:紡客持續時間
七:對不同Files type 的統計信息
八:Pages-URL的統計
九:訪客操作系統瀏覽器等信息
十:其它信息(搜索關鍵字等等)
安裝:
awstats-7.0.zip下載地址:
http://sourceforge.net/projects/awstats/files/AWStats/7.0/awstats-7.0.zip/download
安裝之前首先啟動apache,並查看進程
/usr/local/apache/bin/apachectl start
解壓包:
unzip awstats-7.0.zip
tar -zxvf awstats-7.0.zip
創建存放目錄
mkdir -p /usr/local/awstats
mv awstats-7.0/* /usr/local/awstats
確定係統已經安裝perl
whereis perl
perl: /usr/bin/perl /usr/share/man/man1/perl.1.gz
編譯awstats:
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
#如果系統中沒有安裝apache的話會提示要求你輸入apache配置文件的路徑
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
#如果系統已安裝apache的話,自動會檢測到配置文件
—–> Check for web server install
Found Web server Apache config file ‘/usr/local/apache/conf/httpd.conf’
—–> Check and complete web server config file ‘/usr/local/apache/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).
#輸入y,將日誌記錄方式由’command’改為更詳細的’combined’
Do you want me to setup Apache to write ‘combined’ log files [y/N] ? y
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 " 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 ?
#輸入y創建一個新的配置文件
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:
#輸入配置文件的名字
> AnalyzeApacheLog
—–> 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.AnalyzeApacheLog.conf’
Config file /etc/awstats/awstats.AnalyzeApacheLog.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=AnalyzeApacheLog
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.AnalyzeApacheLog.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for ‘AnalyzeApacheLog’ with command:
> perl awstats.pl -update -config=AnalyzeApacheLog
You can also read your statistics for ‘AnalyzeApacheLog’ with URL:
#查看分析報告的鏈接如下:
> http://localhost/awstats/awstats.pl?config=AnalyzeApacheLog
Press ENTER to finish…
修改配置文件:
vi /etc/awstats/awstats.AnalyzeApacheLog.conf
#LogFile="/var/log/httpd/mylog.log"
LogFile="/home/wwwlog/www.pcstars.com_access.log"
注:
(1)如果同時分析多個日誌
LogFile="/opt/awstats/tools/logresolvemerge.pl /var/apachelogs/30.0206.vblog.log /var/apachelogs/31.0206.vblog.log|"
或
LogFile="/opt/awstats/tools/logresolvemerge.pl /var/apachelogs/*.0206.vblog.log|"
(2)分析使用gzip壓縮過的日誌文件
LogFile="gzip -d </var/log/apache/access.log.gz|"
最後重啟apache,通過web訪問http://IP/awstats/awstats.pl?config=AnalyzeApacheLo
前提條件是apache對應的端口沒有防火牆限製或者SELinux的限制,否則可能會報403錯誤
如果出現這種情況最好找系統管理員解決,不要擅自修改系統文件
最後千萬不要忘了,將下列行加入執行計劃:
/usr/local/awstats/tools/awstats_updateall.pl now
或者
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=AnalyzeApacheLog
config file
/etc/awstats/
Log File analysis
/var/lib/awstats