用awstats分析apache日誌

2021-08-30 10:36:05 字數 3966 閱讀 9603

宣告:[email protected]原創

1.安裝apache(略)

2.安裝cronolog(日誌擷取工具)

tar zxf cronolog-1.6.2.tar.gz

cd cronolog-1.6.2

./configure

make

make install

3.配置apache

在中加入類似:

customlog "|/usr/local/sbin/cronolog /usr/local/apache2/logs/%y/%m/%d/bbs.testtimes.net-access_log" combined

errorlog "|/usr/local/sbin/cronolog /usr/local/apache2/logs/%y/%m/%d/bbs.testtimes.net-error_log"

的日誌分年月日擷取的設定。

4.安裝awstats(最新穩定版6.9)

tar jxf awstats-6.9.tar.bz2

mv awstats-6.9 /usr/local/awstats

chown -r root:root awstats

chmod -r 755 awstats

cd /usr/local/awstats/tools

perl awstats_configure.pl

隨後跟隨設定嚮導:

do you want me to setup apache to write 'combined' log files [y/n] ?y

do you want me to build a new awstats config/profile file (required if first install) [y/n] ?y

yourwebsite, virtualserveror profile name:

>www.testtimes.net

directory path to store config file(s) (enter for default): //直接回車,預設路徑/etc/awstats

配置結束後,嚮導程式自動在apache配置檔案httpd.conf中加入awstats的對應段落。如:

## 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.

#options none

allowoverride none

order allow,deny

allow from all

5.建立資料夾

mkdir -p /var/lib/awstats

6.給awstats訪問設定密碼

/usr/local/apache2/bin/htpasswd -cb /etc/awstats/htpasswd admin 123456

在apache配置檔案httpd.conf最後新增一段:

authtype basic

authname "awstat access"

authuserfile "/etc/awstats/htpasswd"

require valid-user

7.重啟apache

/usr/local/apache2/bin/apachectl restart

8.安裝國家和城市外掛程式

tar zxf geo-ip-pureperl-1.23.tar.gz

cd geo-ip-pureperl-1.23

perl makefile.pl

make

make install

tar zxf geoip-1.4.6.tar.gz

cd geoip-1.4.6

./configure

make

make install

tar zxf geo-ip-1.38.tar.gz

cd geo-ip-1.38

perl makefile.pl

make

make install

gzip -d geolitecity.dat.gz

cp geolitecity.dat /usr/local/share/geoip/

gzip -d geoip.dat.gz

cp geoip.dat /usr/local/share/geoip/

9.安裝qq純真ip庫解析外掛程式

cp qqhostinfo.pm /usr/local/awstats/wwwroot/cgi-bin/plugins

cp qqwry.pl /usr/local/awstats/wwwroot/cgi-bin/plugins

編輯qqwry.pl,把./qqwry.dat 改為 $/plugins/qqwry.dat

上傳qqwry.dat到/usr/local/awstats/wwwroot/cgi-bin/plugins目錄下

10.安裝net-xwhois

tar zxf net-xwhois-0.90.tar.gz

cd net-xwhois-0.90

perl makefile.pl

make

make install

11.編輯awstats配置檔案

配置檔案位於/etc/awstats目錄下,修改如下:

logfile="/usr/local/apache2/logs/%yyyy/%mm/%dd/www.testtimes.net-access_log"

sitedomain="www.testtimes.net"

注:對於多網域名稱的日誌分析,每個網域名稱對應乙個日誌檔案,可以複製後修改其中的logfile、sitedomain這兩項即可。

開啟如下的loadplugin:

loadplugin="tooltips"

loadplugin="decodeutfkeys"

loadplugin="geoip geoip_standard /usr/local/share/geoip/geoip.dat"

loadplugin="geoip_city_maxmind geoip_standard /usr/local/share/geoip/geolitecity.dat"

loadplugin="hostinfo"

loadplugin="qqhostinfo"(該項不存在,手動新增的)

13.新增crontab

crontab -e

* */3 * * * /usr/local/awstats/tools/awstats_updateall.pl now  (每3小時執行一次)

注:以上是多網域名稱的情況,最簡單就是那樣了,對於單網域名稱也可以寫成/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.testtimes.net

AWStats日誌分析

提前安裝httpd與bind軟體包,並啟動服務 yum install httpd bind y配置dns服務主配置檔案 vim etc named.conf修改後如圖所示 配置dns區域配置檔案 vim etc named.rfc1912.zones修改後如圖所示 配置區域資料配置檔案 cp p ...

awstats 日誌分析

tmp awstats awstats.ezrydel.com.conf logfile usr local apache domlogs ezrydel.com perl版就很多 在強大的google analytics的出現,很少有好用的訪問統計工具。那個時候有自己伺服器的,會使用awstats...

awstats日誌分析小結(1)

awststs是乙個非常好用的日誌統計工具,下面我對其他主要web server proxy nginx,squid,lighttpd,httpd 的日誌如何進行分析展開說明。color red awstats日誌分析之apache color apache 修改 apache conf httpd...