wget http://awstats.sourceforge.net/files/awstats-7.0.tar.gz
tar -zxvf awstats-7.0.tar.gz
mv awstats-7.0 /usr/local/awstats
chown -R root:root /usr/local/awstats
chmod -R =rwX /usr/local/awstats
chmod +x /usr/local/awstats/tools/*.pl
chmod +x /usr/local/awstats/wwwroot/cgi-bin/*.pl
cd /usr/local/awstats/tools
./awstats_configure.pl
#現在進入配置文件,按照下面的輸入
# none (我這裏是nginx 不是apache,所以是none)
# y (創建新的一個配置文件)
# firefoxbug (基於什麼域名)
#
#A SIMPLE config file has been created: /etc/awstats/awstats.firefoxbug.conf
#You should have a look inside to check and change manually main parameters.
#You can then manually update your statistics for 'firefoxbug' with command:
#> perl awstats.pl -update -config=firefoxbug
#You can also build static report pages for 'firefoxbug' with command:
#> perl awstats.pl -output=pagetype -config=firefoxbug
#-----> Create config file '/etc/awstats/awstats.firefoxbug.conf'
# Config file /etc/awstats/awstats.firefoxbug.conf create
以上步驟默認會產生配置文件 ==>> /etc/awstats/awstats.firefoxbug.conf
awstats 配置文件的命名規則:awstats.website.conf
修改配置文件
# vim /etc/awstats/awstats.firefoxbug.conf
# LogFile="/var/log/httpd/mylog.log" ==>> LogFile="/path/to/you_website_log_path"
創建awstats統計結果的數據庫存放目錄
mkdir -p /var/lib/awstats
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=firefoxbug
分析日誌:運行後將這樣的日誌統計結果歸檔到一個AWStats的數據庫(純文本)裏;
然後是輸出:分兩種形式
1. 一種是通過cgi程序讀取統計結果數據庫輸出;
2. 一種是運行後臺腳本將輸出導出成靜態文件;
統計分析完成後,結果還在 Awstats 的數據庫中。在 Apache 上,可以直接打開 Perl 程序的網頁查看統計。 但Nginx 對 Perl 支持並不好,所以要換個方法,利用 awstats 的工具將統計的結果生成靜態文件,具體的步驟如下:
先生成存放awstats生成的靜態文件的目錄,我這裏用的是/var/www/HduISA/awstats
mkdir /var/www/HduISA/awstats
/usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=firefoxbug -lang=cn -dir=/var/www/HduISA/awstats/firefoxbug
awstats_buildstaticpages.pl 會根據 -config 的參數去讀取裏面的 DirData 路徑下數據庫配置文件,然後生成靜態的html文件,生成的文件重定向到/var/www/HduISA/awstats/firefoxbug。
最後是nginx的配置文件,根據自己路徑配置
server {
listen 80;
server_name localhost;
root /var/www/HduISA;
index index.html;
location ~ ^/awstats/ { # awstats 靜態頁面目錄
root /var/www/HduISA/awstats
autoindex on; #可以目錄瀏覽你的多個域名的目錄用於分析
index index.html;
access_log off;
}
location ~ ^/icon/ { # 圖標目錄
root /usr/local/awstats/wwwroot;
index index.html;
access_log off;
}
}