Awstats是一個基於Perl的免費很是簡潔並且強大有個性的網站日誌分析工具。AWStats 是一個免費的強大而有個性的工具,帶來先進的網絡,流量,FTP或郵件服務器統計圖. 本日誌分析器做爲CGI或從命令行在數個圖形網頁中顯示你日誌中包含的全部可能信息. 它利用一部分檔案資料就能常常很快地處理大量日誌檔案, 它能分析日誌文件來自從各大服務器工具 ,如 Apache日誌檔案 s (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C的日誌格式)及許多其餘網站,Proxy(代理服務器)、Wap、流量服務器、郵件服務器和一些 FTP服務器 .web
它能夠統計您站點的以下信息:apache
一:訪問量,訪問次數,頁面瀏覽量,點擊數,數據流量等瀏覽器
二:精確到每個月、每日、每小時的數據bash
三:訪問者國家服務器
四:訪問者IP網絡
五:Robots/Spiders的統計ide
六:訪客持續時間工具
七:對不一樣Files type 的統計信息網站
八:Pages-URL的統計ui
九:訪客操做系統瀏覽器等信息
十:其它信息(搜索關鍵字等等)
一、解壓
tar zxvf awstats-6.6.tar.gz mv awstats-6.6 /usr/local/awstats cd /usr/local/awstats/tools/ perl awstats_configure.pl
二、安裝
#因爲腳本有所區別,可能提示內容的順序有所區別,僅供參考
(1)
-----> Running OS detected: Linux, BSD or Unix
Warning: AWStats standard directory on Linux OS is '/usr/local/awstats'.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/opt/awstats
to standard directory:
/usr/local/awstats
And then, run configure.pl from this location.
Do you want to continue setup from this NON standard directory [yN] ?
這時選擇y回車。
(2)
-----> Check for web server install
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
第一次使用請輸入Apache的httpd.conf路徑,例如/opt/sina/apache/conf/httpd.conf
之後若是再使用perl awstats_configure.pl生成配置文件,則能夠輸入none跳過。
(3)
-----> Check and complete web server config file '/opt/sina/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).
Do you want me to setup Apache to write 'combined' log files [y/N] ?
選擇y,將日誌記錄方式由CustomLog /yourlogpath/yourlogfile common改成更詳細的CustomLog /yourlogpath/yourlogfile combined
(4)
-----> Update model config file '/opt/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
(5)
-----> 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:
>
輸入站點名稱,例如wp,只是爲了區分站點
(6)
-----> 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):
>
輸入AWStats配置文件存放路徑,通常直接回車則使用默認路徑/etc/awstats
(7)
-----> 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:
/opt/awstats/wwwroot/cgi-bin/awstats.pl -update -config=sina
Or if you have several config files and prefer having only one command:
/opt/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...
按回車鍵繼續
(8)
A SIMPLE config file has been created: /opt/awstats/etc/awstats.sina.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'sina' with command:
> perl awstats.pl -update -config=sina
You can also read your statistics for 'sina' with URL:
> http://localhost/awstats/awstats.pl?config=wp
Press ENTER to finish...
按回車鍵結束
四、修改awstats.sina.conf配置
vi /etc/awstats/awstats.sina.conf
修改日誌路徑
搜索LogFile
改成要分析的Apache日誌路徑與文件名。
#123服務器上的日誌命名格式
LogFile="/usr/local/apache2/logs/wp_access_%YYYY%MM%DD.log"
根據配置文件,新建awstats數據目錄
mkdir -pv /var/lib/awstats DirData="/var/lib/awstats"
五、更新分析報告
perl /opt/awstats/wwwroot/cgi-bin/awstats.pl -config=wp -update
若是提示錯誤,可能的緣由
日誌沒有清空
解決:中止Apache,並將當前日誌清空,或者把以前的日誌文件重命名
ok!
六、查看分析報告
http://localhost/awstats/awstats.pl?config=wp
七、配置IP歸屬地插件
首先要安裝perl-MCPAN
yum install perl-MCPAN perl -MCPAN -e 'install "Geo::IP"' perl -MCPAN -e 'install "Geo::IPfree"'
而後修改配置文件中的GeoIP路徑信息
LoadPlugin="geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat" LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/share/GeoIP/GeoLiteCity.dat"
下次awstats更新時就會顯示歸屬地
能夠把更新命令寫入計劃任務
[root@iZ25k899iwfZ ~]# cat /scripts/awstats_up.sh perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=wp -update [root@iZ25k899iwfZ ~]# crontab -l */5 * * * * /scripts/awstatus_up.sh http://localhost/awstats/awstats.pl?config=wp
OK,這樣就會出現你所想要的分析報告了。
Game Over !