用AWStats分析网站日志
生活随笔
收集整理的這篇文章主要介紹了
用AWStats分析网站日志
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
AWStats 是一個免費的強(qiáng)大而有個性的工具,帶來先進(jìn)的網(wǎng)絡(luò),流量,FTP或郵件服務(wù)器統(tǒng)計圖. 它能分析日志文件來自從各大服務(wù)器工具 ,如 Apache日志檔案? (NCSA combined or common),? IIS (W3C),Proxy、Wap、流量服務(wù)器、郵件服務(wù)器和一些FTP服務(wù)器等等。 注: 1:需要系統(tǒng)正常運行perl環(huán)境。 2:apache運行正常。 1:到官方網(wǎng)站下載最新版本,目前的版本是Awstats 6.9 下載后上傳到主機(jī)上進(jìn)行安裝和配置。 2:其實awstats安裝是非常容易的,大致的步驟如下: [root@centos opt]#tar zxvf awstats-6.6.tar.gz [root@centos opt]# cd awstats-6.6 [root@centos awstats-6.6]# cd tools/ [root@centos tools]# perl awstats_configure.pl Do you want to continue setup from this NON standard directory [yN] ? y? ?
//輸入你的web server的配置文件路徑 使用none跳過設(shè)置
Config file path ('none' to skip web server setup):? ???
> none
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y
Your web site, virtual server or profile name:
> [url]http://www.test.net/[/url] 直接回車 使用默認(rèn)路徑 /etc/awstats
Directory path to store config file(s) (Enter for default):? ?? ?
> /etc/awstats
再次敲回車,到此為止awstats安裝完成,(是不是覺得太簡單了啊!)接下來配置awstats: A:[root@centos /]# cd /etc/awstats/ (這個目錄是存放awstats配置文件的) [root@centos awstats]# vi awstats.[url]www.test.net.conf[/url] #LogFile="/var/log/httpd/mylog.log"
LogFile="/usr/local/apache2/logs/access_log" (修改你要分析的日志文件的路徑) //日志分析結(jié)果輸出目錄 確保該目錄有寫權(quán)限
? ? DirData="/var/www/awstats/test/dirdata"
//指定日志格式 1 - Apache combined logs??2 - IIS
? ? LogFormat=1?? (如果是分析apache 可以用默認(rèn)的,如果是分析IIS就應(yīng)該選2) AllowToUpdateStatsFromBrowser=1 允許查看的時候進(jìn)行更新日志數(shù)據(jù) :wq?? 保存退出。 B: 運行:perl /opt/awstats-6.6/wwwroot/cgi-bin/awstats.pl -update -config=www.test.net 如果是第一次運行更新的話,awstats會出現(xiàn)錯誤:AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log。其實從錯誤信息中不難看出原因,解決辦法就是把用分析的日志文件刪除,重新加載即可。 為了讓系統(tǒng)自動作業(yè),把命令加入系統(tǒng)的crontab, [root@centos awstats]# crontab -e 30 23 * * * root perl /opt/awstats-6.6/wwwroot/cgi-bin/awstats.pl -update -config=www.test.net (每天晚上11:30進(jìn)行日志分析) 訪問權(quán)限配置
有時候網(wǎng)站的日志信息不想給競爭對手看到,所以需要對日志查看進(jìn)行授權(quán),授權(quán)方式如下:
編輯apache的配置文件 vi /usr/local/apache2/conf/httpd.conf
<Directory "/opt/awstats-6.6/wwwroot">
??? Options None
?? # AllowOverride None
??? AllowOverride AuthConfig
??? Order allow,deny
??? Allow from all AuthType Basic
??? AuthName "Restricted Files"
??? AuthUserFile /usr/local/apache2/conf/passwords
??? Require user dbasky
</Directory> 利用apapche的htpasswd生成個系統(tǒng)的用戶,達(dá)到系統(tǒng)的加密: /usr/local/apache2/bin/htpasswd -c /usr/local/apache2/conf/passwords admin 此時輸入二次密碼確認(rèn)密碼. 配置完成后,重啟apapche,ok!awstats就配置完成了,可以看看我們的成果了:
//輸入你的web server的配置文件路徑 使用none跳過設(shè)置
Config file path ('none' to skip web server setup):? ???
> none
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y
Your web site, virtual server or profile name:
> [url]http://www.test.net/[/url] 直接回車 使用默認(rèn)路徑 /etc/awstats
Directory path to store config file(s) (Enter for default):? ?? ?
> /etc/awstats
再次敲回車,到此為止awstats安裝完成,(是不是覺得太簡單了啊!)接下來配置awstats: A:[root@centos /]# cd /etc/awstats/ (這個目錄是存放awstats配置文件的) [root@centos awstats]# vi awstats.[url]www.test.net.conf[/url] #LogFile="/var/log/httpd/mylog.log"
LogFile="/usr/local/apache2/logs/access_log" (修改你要分析的日志文件的路徑) //日志分析結(jié)果輸出目錄 確保該目錄有寫權(quán)限
? ? DirData="/var/www/awstats/test/dirdata"
//指定日志格式 1 - Apache combined logs??2 - IIS
? ? LogFormat=1?? (如果是分析apache 可以用默認(rèn)的,如果是分析IIS就應(yīng)該選2) AllowToUpdateStatsFromBrowser=1 允許查看的時候進(jìn)行更新日志數(shù)據(jù) :wq?? 保存退出。 B: 運行:perl /opt/awstats-6.6/wwwroot/cgi-bin/awstats.pl -update -config=www.test.net 如果是第一次運行更新的話,awstats會出現(xiàn)錯誤:AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log。其實從錯誤信息中不難看出原因,解決辦法就是把用分析的日志文件刪除,重新加載即可。 為了讓系統(tǒng)自動作業(yè),把命令加入系統(tǒng)的crontab, [root@centos awstats]# crontab -e 30 23 * * * root perl /opt/awstats-6.6/wwwroot/cgi-bin/awstats.pl -update -config=www.test.net (每天晚上11:30進(jìn)行日志分析) 訪問權(quán)限配置
有時候網(wǎng)站的日志信息不想給競爭對手看到,所以需要對日志查看進(jìn)行授權(quán),授權(quán)方式如下:
編輯apache的配置文件 vi /usr/local/apache2/conf/httpd.conf
<Directory "/opt/awstats-6.6/wwwroot">
??? Options None
?? # AllowOverride None
??? AllowOverride AuthConfig
??? Order allow,deny
??? Allow from all AuthType Basic
??? AuthName "Restricted Files"
??? AuthUserFile /usr/local/apache2/conf/passwords
??? Require user dbasky
</Directory> 利用apapche的htpasswd生成個系統(tǒng)的用戶,達(dá)到系統(tǒng)的加密: /usr/local/apache2/bin/htpasswd -c /usr/local/apache2/conf/passwords admin 此時輸入二次密碼確認(rèn)密碼. 配置完成后,重啟apapche,ok!awstats就配置完成了,可以看看我們的成果了:
轉(zhuǎn)載于:https://blog.51cto.com/mibon/142467
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的用AWStats分析网站日志的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Dreamweaver中如何格式化代码
- 下一篇: JEECG 命名规范