[1.] apt-get install awstats-6.5-3.fc4
 
[2.] vi /etc/httpd/conf/httpd.conf

CustomLog logs/ssorc.tw-access_log combined

[3.] 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/share/awstats/" must reflect your AWStats install path.
#
Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/share/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# Additional Perl modules
<IfModule mod_env.c>
SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins
</IfModule>

[4.] vi /etc/awstats/awstats.ssorc.tw.conf

# Apache 的記錄登錄檔

LogFile="/var/log/httpd/ssorc.tw-access_log"    

 

LogType=W

 

LogFormat=1

 

# 主機名稱

SiteDomain="ssorc.tw"       

 

# 輸出目錄
DirData="/var/lib/awstats"

[3.] 執行,ssorc.tw就是設定檔awstats.ssorc.tw.conf中的SiteDomain
         perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=ssorc.tw -update

 

[4.] 排程,(rpm安裝的已排在每小時了)

00 * * * * root perl /usr/share/awstats/tools/awstats_updateall.pl now -confdir="/etc/awstats" -awstatsprog="/usr/share/awstats/wwwroot/cgi-bin/awstats.pl" >/dev/null

          依–confdir=/etc/awstats就會更新底下的 awstats.localhost.localdomain.conf及 awstats.ssorc.tw.conf了

[root@ssorc tools]# perl /usr/share/awstats/tools/awstats_updateall.pl now -configdir="/etc/awstats" -awstatsprog="/usr/share/awstats/wwwroot/cgi-bin/awstats.pl"

Running '"/usr/share/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=localhost.localdomain -configdir="/etc/awstats"' to update config localhost.localdomain
Create/Update database for config "/etc/awstats/awstats.localhost.localdomain.conf" by AWStats version 6.6 (build 1.887)
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…
Jumped lines in file: 0
Parsed lines in file: 0
 Found 0 dropped records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 0 new qualified records.

Running '"/usr/share/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=ssorc.tw -configdir="/etc/awstats"' to update config ssorc.tw
Create/Update database for config "/etc/awstats/awstats.ssorc.tw.conf" by AWStats version 6.6 (build 1.887)
From data in log file "/var/log/httpd/ssorc.tw-access_log"…
Phase 1 : First bypass old records, searching new record…
Direct access after last parsed record (after line 51753)
Jumped lines in file: 51753
 Found 51753 already parsed records.
Parsed lines in file: 109
 Found 1 dropped records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 108 new qualified records.

[5.] 瀏覽 http://ssorc.tw/awstats/awstats.pl?config=ssorc.tw

 

[6.] 建立其它報告方式,(以下為靜態方式呈現)

perl awstats.pl -config=ssorc.tw -output  -staticlinks > awstats.main.html
perl awstats.pl -config=ssorc.tw -output=alldomains -staticlinks > awstats.alldomains.html
perl awstats.pl -config=ssorc.tw -output=allhosts -staticlinks > awstats.allhosts.html
perl awstats.pl -config=ssorc.tw -output=lasthosts -staticlinks > awstats.lasthosts.html
perl awstats.pl -config=ssorc.tw -output=unknownip -staticlinks > awstats.unknownip.html
perl awstats.pl -config=ssorc.tw -output=alllogins -staticlinks > awstats.alllogins.html
perl awstats.pl -config=ssorc.tw -output=lastlogins -staticlinks > awstats.lastlogins.html
perl awstats.pl -config=ssorc.tw -output=allrobots -staticlinks > awstats.allrobots.html
perl awstats.pl -config=ssorc.tw -output=lastrobots -staticlinks > awstats.lastrobots.html
perl awstats.pl -config=ssorc.tw -output=urldetail -staticlinks > awstats.urldetail.html
perl awstats.pl -config=ssorc.tw -output=urlentry -staticlinks > awstats.urlentry.html
perl awstats.pl -config=ssorc.tw -output=urlexit -staticlinks > awstats.urlexit.html
perl awstats.pl -config=ssorc.tw -output=browserdetail -staticlinks > awstats.browserdetail.html
perl awstats.pl -config=ssorc.tw -output=osdetail -staticlinks > awstats.osdetail.html
perl awstats.pl -config=ssorc.tw -output=unknownbrowser -staticlinks > awstats.unknownbrowser.html
perl awstats.pl -config=ssorc.tw -output=unknownos -staticlinks > awstats.unknownos.html
perl awstats.pl -config=ssorc.tw -output=refererse -staticlinks > awstats.refererse.html
perl awstats.pl -config=ssorc.tw -output=refererpages -staticlinks > awstats.refererpages.html
perl awstats.pl -config=ssorc.tw -output=keyphrases -staticlinks > awstats.keyphrases.html
perl awstats.pl -config=ssorc.tw -output=keywords -staticlinks > awstats.keywords.html
perl awstats.pl -config=ssorc.tw -output=errors404 -staticlinks > awstats.errors404.htm

備註: 如果有舊記錄要多加個 -update

Q&A) 如何作才不會因log檔rotate時怕會有資料loss掉
      vi /etc/logrotate.d/httpd

/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    prerotate
        /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=ssorc.tw
    endscript

    postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}

   ref: http://awstats.sourceforge.net/docs/awstats_faq.html#ROTATE

Q&A) 何如處理多個記錄檔
      vi /etc/awstats/awstats.ssorc.tw.conf

LogFile="/usr/share/awstats/tools/logresolvemerge.pl /var/log/httpd/ssorc.tw-access_log* |"

   ref: http://awstats.sourceforge.net/docs/awstats_faq.html#MULTILOG 

Q.) 在用以搜尋的關鍵字句 (前 10) 出現亂碼 – 2008/02/14
A.) 原因為原語言檔為 big5,需將檔案轉成 utf-8 才能正常顯示,如果你不面自行轉換的話可以至 http://cha.homeip.net/blog/archives/2005/02/e_awstats_ec_ut_1.html 來 下載 http://cha.homeip.net/blog/archives/awstats-tw-utf8.txt (for AWStats v6.3),看是要覆蓋原檔或是使用新檔,但如果使用新檔的話要修改 conf 裡的 Lang=tw-utf8 參數。
自行修改
   1) iconv  -f big5 -t utf8 awstats-tw.txt -o awstats-tw-utf8.txt
   2) vi awstats-tw-utf8.txt

PageCode=big5
改為
PageCode=utf8
Related posts 相關文章
apache httpd 2.4.58 有些安全性更新
More...
Apache 有 path traversal 目錄遍歷的漏洞
More...
CentOS7 透過 systemd 自動讓服務 restart 重啟
More...
用 GoAccess 即時分析 IIS Access Log
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。