鍓嶈█
鏈枃涓嬌鐢ㄧ殑鏄痑wstats 7.0鐗堟湰銆?br /> 姝ょ増鏈鍔犱簡瀵箇in7鐨勬敮鎸佷互鍙婁竴浜涙洿鏂扮殑鐗規с?/p>
New features/improvements:
- Detect Windows 7.
- Can format numbers according to language.
- More mime types.
- Added geoip_asn_maxmind plugin.
- Geoip Maxmind city plugin have now override file capabilities to complete
missing entries in geoip maxmind database.
- Added graphgooglechartapi to use online Google chart api to build graph.
- Can show map of country to report countries when using graphgooglechartapi.
- Part of codes was change to use more functions and have a cleaner code.
- Added parameter to ignore missing log files when merging for a site on
multiple servers where a single server may not have created a log for a given day.
- Update robots database.
- Added Download tracking where certain mime types are defined as downloads
and HTTP status 206 is tracked as download continuation
Awstats 鏄湪 SourceForge 涓婂彂灞曞緢蹇殑涓涓熀浜?Perl 鐨?WEB 鏃ュ織鍒嗘瀽宸ュ叿錛屼竴涓厖鍒嗙殑鏃ュ織鍒嗘瀽璁? Awstats 鏄劇ず鎮ㄤ笅鍒楄祫鏂?
- 璁塊棶嬈℃暟銆佺嫭鐗硅瀹漢鏁?
- 璁塊棶鏃墮棿鍜屼笂嬈¤闂?
- 浣跨敤鑰呰璇併佹渶榪戣璇佺殑璁塊棶,
- 姣忓懆鐨勯珮宄版椂闂?欏墊暟,鐐瑰嚮鐜?姣忓皬鏃跺拰涓鍛ㄧ殑鍗冨瓧鑺?,
- 鍩熷悕/鍥藉鐨勪富鏈鴻瀹?欏墊暟,鐐瑰嚮鐜?瀛楄妭,269鍩熷悕/鍥藉媯嫻? geoip 媯嫻?,
- 涓繪満鍚嶅崟,鏈榪戣闂拰鏈В鏋愮殑 IP 鍦板潃鍚嶅崟
- 澶у鏁扮湅榪囩殑榪涘嚭欏甸潰,
- 妗f綾誨瀷,
- 緗戠珯鍘嬬緝緇熻琛?mod_gzip 鎴栬?mod_deflate),
- 浣跨敤鐨勬搷浣滅郴緇?(姣忎釜鎿嶄綔緋葷粺鐨勯〉鏁?鐐瑰嚮鐜?,瀛楄妭, 35 OS detected),
- 浣跨敤鐨勬祻瑙堝櫒,
- 鏈哄櫒浜鴻闂?媯嫻?319 涓満鍣ㄤ漢),
- 锠曡櫕鏀誨嚮 (5 涓爼铏鏃?,
- 鎼滅儲寮曟搸錛屽埄鐢ㄥ叧閿瘝媯绱㈡壘鍒頒綘鐨勫湴鍧,
- HTTP 鍗忚閿欒(鏈榪戞煡闃呮病鏈夋壘鍒扮殑欏甸潰),
- 鍏朵粬鍩轟簬 URL 鐨勪釜鎬ф姤瀵?閾炬帴鍙傛暟, 娑夊強緇煎悎琛岄攢棰嗗煙鐩殑.
- 璐電綉绔欒鍔犲叆”鏈鍠滅埍鐨勪功絳?#8221;.嬈℃暟.
- 灞忓箷澶у皬(闇瑕佸湪绱㈠紩欏佃ˉ鍏呬竴浜?HTML 鏍囩).
- 嫻忚鍣ㄧ殑鏀寔姣斾緥: Java, Flash, RealG2 reader, Quicktime reader, WMA reader, PDF reader.
- 璐熻澆騫寵 鏈嶅姟鍣ㄦ瘮鐜囬泦緹ゆ姤鍛?
Awstats 鐨勮繍琛屾槸闇瑕?PERL 鐜鐨勬敮鎸侊紝浠?awstats 鐨勬枃妗f潵鐪嬶紝瀹冨 Apache HTTP Server 鐨勬敮鎸佹槸闈炲父瀹岀編鐨勶紝鑰屽綋鎴戜滑鎶?Web 鏈嶅姟鍣ㄦ崲鎴?Nginx 鍚庯紝瑕佽繍琛?awstats 鍙樺緱寰堥夯鐑︺傞鍏?Nginx 鏈韓瀵?Perl 鐨勬敮鎸佹槸姣旇緝寮辯殑錛岀敋鑷沖畼鏂逛篃涓嶅緩璁嬌鐢紱鍙﹀鍦ㄦ棩蹇楁牸寮忎笂鏈夐渶瑕佷慨鏀瑰悗鎵嶈兘榪愯銆?/p>
鏃ュ織鍒囧壊
鏈枃涓昏浠嬬粛閫氳繃璁?awstats 瀵規棩蹇楃粺璁$殑緇撴灉鐢熸垚闈欐侀〉闈紝鐒跺悗閫氳繃 Nginx 杈撳嚭浠ヨ揪鍒扮粺璁?Nginx 璁塊棶鏃ュ織鐨勬晥鏋滐紝鍏朵腑榪樺寘鎷浣曡 Nginx 鑷姩鍒囧壊鏃ュ織鏂囦歡銆傚浜巒ginx鐨勬棩蹇楋紝鎴戠殑鍋氭硶鏄寜澶╁垏鍓層傜劧鍚庡瓨鍏ユ棩鏈熷艦寮忕殑鐩綍涓茍鍘嬬緝銆?/p>
闇瑕佹敞鎰忕殑鏄紝nginx鐨勬棩蹇楀簲璇ラ伒寰互涓嬫牸寮忥紝鎵嶅彲浠ヨawstats璇嗗埆錛屽瀹氫箟鏃ュ織鏍煎紡
1 2 3 | log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
|
浣跨敤鏃ュ織鏍煎紡
1 | access_log /home/www/logs/access.log main;
|
榪欓噷闇瑕佹湁涓涓皬鎶宸х殑鎻愮ず錛氭妸log_format榪欐浠g爜鏀懼湪浣爊ginx鐨刪ttp鐨勫畾涔夋涓紝鍙互鍦ㄤ笅闈㈢殑姣忎竴涓猻erver涓紩鐢ㄦ鏍煎紡銆備笉蹇呭湪姣忎釜server閲岄潰閮藉幓瀹氫箟鏍煎紡銆?br /> 鏈枃涓嶈濡備綍瀹夎nginx錛岀◢鍚庢垜灝嗗彂甯冩垜鐨刲nmp涓閿畨瑁呭寘(linux nginx mysql php)銆傚叏緙栬瘧+浼樺寲鑷姩鍖栧畨瑁咃紝浣跨敤php-fpm榪愯php鐨刦astcgi榪涚▼銆?/p>
鎴戝啓浜嗕竴涓畾鏃跺垏鍓叉棩蹇楃殑鑴氭湰銆傛瘡澶?:00寮濮嬫墽琛岋紝鍒囧壊鏄ㄥぉ鐨勬棩蹇楋紙浜ょ敱awstats鍒嗘瀽錛夛紝鍘嬬緝鍓嶅ぉ鐨勬棩蹇楋紙鍘嬬緝鏃ュ織鍙噺灝忓瓨鍌ㄧ┖闂達紝涓洪槻 姝wstats娌℃湁鍒嗘瀽瀹屽氨琚帇緙╋紝鎵浠ュ彧鍘嬬緝鍓嶅ぉ鐨勬棩蹇楋級銆傚鏋滀綘鐨刵ginx鍜宭og鏂囦歡鏀劇殑璺緞鍜屾垜鐨勪笉涓鏍鳳紝璇峰搴斾慨鏀廣?/p>
杈撳叆浠ヤ笅鍐呭
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/bin/bash
# This script run at 00:00
# cut yesterday log and gzip the day before yesterday log files.
# yesterday logs to awstats
# The Nginx logs path
logs_path="/home/www/logs/"
date_dir=${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/$(date -d "yesterday" +"%d")/
gzip_date_dir=${logs_path}$(date -d "-2 day" +"%Y")/$(date -d "-2 day" +"%m")/$(date -d "-2 day" +"%d")/
mkdir -p $date_dir
mv ${logs_path}*access.log $date_dir
/usr/local/nginx/sbin/nginx -s reopen
/usr/bin/gzip ${gzip_date_dir}*.log
|
鐒跺悗璁╁畠姣忓ぉ0鏃惰搗寮濮嬭繘琛岋紝鎵цcrontab -e鍔犲叆浠ヤ笅浠g爜鍐嶆寜:wq淇濆瓨閫鍑猴紝榪欓噷鎴戝皢姝よ剼鏈斁鍦?root/涓嬶紝鍒囪瑕佺粰瀹冨彲鎵ц鏉冮檺錛坈hmod +x cut_log.sh錛?
1 | 00 00 * * * /bin/bash /root/cut_log.sh
|
榪欐牱灝卞彲浠ユ瘡澶╁噷閲岃嚜鍔ㄥ垏鍓叉槰澶╃殑鏃ュ織鍒頒互鏃ユ湡涓虹洰褰曠粨鏋勭殑鐩綍涓傚彲浠ョ暀瀛樹互鍚庢煡璇€傜暀鐫鏄ㄥぉ鐨勬棩蹇椾氦緇欎笅闈㈢殑awstats鏉ュ垎鏋愶紝鍘嬬緝鍓嶅ぉ鐨勬棩蹇楋紙鍓嶅ぉ鐨勫凡緇忚鍒嗘瀽榪囦簡錛夈?/p>
瀹夎鍜岄厤緗產wstats
涓嬭澆鏈鏂扮殑 awstats錛屾垜浣跨敤鐨勬槸榪勪粖涓烘鏈鏂扮殑7.0鐗堟湰
瀹夎鍒?usr/local涓嬶紝榪欎釜璺緞鏄範鎯傚ぇ閮ㄥ垎浜轟繚鎸佺殑鑹ソ涔犳儻銆?/p>
1 2 3 | 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
|
淇敼鏉冮檺錛寃get涓嬭澆涓嬫潵鐨勫寘涓潈闄愭槸闈瀝oot鐨勶紝璧嬩簣榪囨潈闄愪箣鍚庯紝.pl鐨勬枃浠朵篃灝卞彲浠ヨ繍琛屼簡銆?/p>
1 2 3 4 | 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
|
鐒跺悗鎵ц tools 鐩綍涓殑 awstats_configure.pl 閰嶇疆鍚戝錛屽垱寤轟竴涓柊鐨勭粺璁?/p>
榪愯(娉ㄦ剰榪欓噷瑕佸湪褰撳墠鐩綍榪愯銆傚惁鍒欎細鏈変竴浜涘叧浜庢爣鍑嗙洰褰曠殑鎻愮ず銆?
1 2 | cd /usr/local/awstats/tools
./awstats_configure.pl
|
灝嗕細鏈夊涓嬩竴浜涙彁紺猴細
1 2 3 4 5 6 7 8 9 10 | -----> Running OS detected: Linux, BSD or Unix
-----> 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):
>none #榪欓噷娣籲one騫跺洖杞︼紝鍥犱負鎴戜滑娌℃湁浣跨敤apache
|
鍥炶濺涔嬪悗涓嬩竴涓夐」
1 2 3 4 5 6 7 8 9 10 11 | Your web server config file(s) could not be found.
You will need to setup your web server manually to declare AWStats
script as a CGI, if you want to build reports dynamically.
See AWStats setup documentation (file docs/index.html)
-----> Update model config file '/usr/local/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] ?
|
#榪欓噷閫塝錛屽垱寤轟竴涓柊鐨勯厤緗枃浠?/p>
1 2 3 4 5 6 | -----> 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:
>akii.org #榪欓噷杈撳叆浣犺鍒嗘瀽鐨勫煙鍚嶏紝鎴栨槸闅忎究涓涓綘鏄撹鐨勯厤緗悕騫跺洖杞?/code>
|
鎺ヤ笅鏉ヨ瀹氫箟浣犵殑閰嶇疆鏂囦歡瀛樻斁鐨勮礬寰勶紝鍙敤榛樿
1 2 3 4 5 | -----> 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):
> #鐩存帴鍥炶濺錛屼嬌鐢ㄩ粯璁よ礬寰?etc/awstats
|
鍥炶濺鍚庣殑鎻愮ず
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | -----> Create config file '/etc/awstats/awstats.akii.org.conf'
Config file /etc/awstats/awstats.akii.org.conf created.
-----> 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:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=akii.org
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue... #鎸夊洖杞︾戶緇?/code>
A SIMPLE config file has been created: /etc/awstats/awstats.akii.org.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'yuyuanchun.com' with command:
> perl awstats.pl -update -config=akii.org
You can also build static report pages for 'akii.org' with command:
> perl awstats.pl -output=pagetype -config=akii.org
Press ENTER to finish... #鍥炶濺瀹屾垚閰嶇疆鏂囦歡鐨勫垱寤?/code>
|
瀹屾垚閰嶇疆鏂囦歡鐨勫垱寤哄悗錛屾垜浠繕瑕佷慨鏀逛竴涓嬨傚洜涓烘垜浠槸鎸夊ぉ鍒囧壊鐨勬棩蹇楋紝鍒囧壊瀹屾垚鍚庝氦鐢盿wstats鍘誨垎鏋愩傚茍涓嶆槸璁゛wstats鍘誨垎鏃舵鍦ㄦ椂鏃?澧為暱鐨勪篃灝辨槸姝e湪琚啓鍏ョ殑鏃ュ織錛岃繖鏍風殑濂藉鏄笉鑷充簬閬楁紡鏁版嵁錛屽茍涓斿垎鏋愬凡緇忓垏鍓插畬鎴愮殑鏃ュ織錛屾洿涓嶇敤鎷呭績浼氭湁鍐茬獊銆傚潖澶勬槸鎴戜竴澶╁垏鍓蹭竴嬈℃棩蹇楋紝浣犺絳夌浜屽ぉ 鎵嶈兘鐪嬫槰澶╃殑涓浜涜緇嗘暟鎹?/p>
淇敼/etc/awstats/awstats.akii.org.conf錛屾墽琛岋細
1 | vi /etc/awstats/awstats.akii.org.conf
|
鎵懼埌
1 | LogFile="/var/log/httpd/mylog.log"
|
淇敼涓猴細
1 | LogFile="/home/www/logs/%YYYY-24/%MM-24/%DD-24/akii.org_access.log"
|
濡傛灉浣犵殑鏃ュ織璺緞鍜屾垜鐨勪笉涓鏍鳳紝璇蜂慨鏀規垚瀵瑰簲鐨勬棩蹇楁枃浠跺悕銆備互涓婄殑瀹屾暣璺緞鏄垏鍓插悗淇濆瓨鐨刵ginx鏃ュ織鏂囦歡銆傚叾涓?YYYY-24/%MM-24/%DD-24琛ㄧず騫存湀鏃ラ兘鍑忓幓24灝忔椂錛屼篃灝辨槸鏄ㄥぉ鐨勬棩蹇楃洰褰曘備慨鏀瑰畬鎴愬悗鎸?wq淇濆瓨閫鍑恒?/p>
鎺ヤ笅鏉ュ彲浠ユ祴璇曚竴涓媋wstats鍒嗘瀽鏃ュ織浜嗭紙鍓嶆彁鏄綘宸茬粡鏈変簡鍒囧壊榪囩殑鏃ュ織錛屾病鏈夌殑璇濆彲浠ュ厛閫琛屼竴涓嬪垏鍓叉棩蹇楃殑鑴氭湰/root/cut_log.sh錛?/p>
棣栧厛錛岃繕瑕佸垱寤轟竴涓猘wstats鐢ㄤ簬璁板綍鏁版嵁鐨勭洰褰?/p>
1 | mkdir -p /var/lib/awstats
|
鐒跺悗榪愯awstats鐨剋wwroot鐩綍涓殑awatsts.pl鏉ユ祴璇曚竴涓?/p>
1 | /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=akii.org
|
浣犲鏋滅湅鍒扮被浼間笅闈㈢殑鎻愮ず灝辮鏄庨厤緗枃浠墮兘姝g‘浜嗐?/p>
1 2 3 4 5 6 7 8 9 10 11 12 13 | Create/Update database for config "/etc/awstats/awstats.akii.org.conf" by AWStats version 7.0 (build 1.964)
From data in log file "/home/www/logs/2010/07/24/akii.org_access.log"...
Phase 1 : First bypass old records, searching new record...
Direct access after last parsed record (after line 43260)
Jumped lines in file: 43260
Found 43260 already parsed records.
Parsed lines in file: 0
Found 0 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 0 new qualified records
|
緇熻鍒嗘瀽瀹屾垚鍚庯紝緇撴灉榪樺湪 Awstats 鐨勬暟鎹簱涓傚湪 Apache 涓婏紝鍙互鐩存帴鎵撳紑 Perl 紼嬪簭鐨勭綉欏墊煡鐪嬬粺璁°? 浣嗘湰鏂囧紑濮嬫椂宸茬粡鎻愬埌錛孨ginx 瀵?Perl 鏀寔騫朵笉濂斤紝鎵浠ユ垜浠鎹釜鏂規硶錛屽埄鐢?awstats 鐨勫伐鍏峰皢緇熻鐨勭粨鏋滅敓鎴愰潤鎬佹枃浠訛紝鍏蜂綋鐨勬楠ゅ涓嬶細
- 棣栧厛鍦?webroot 鐩綍涓嬪垱寤轟竴涓枃浠跺す銆備緥錛?home/www/awstats
- 鍐欎竴涓剼鏈紝瀹氭湡鎵ц璁?Awstats 鎶婇潤鎬侀〉闈㈢敓鎴愬埌璇ョ洰褰曚腑
鍏堢敓鎴愬瓨鏀綼wstats鐢熸垚鐨勯潤鎬佹枃浠剁殑鐩綍錛屾垜榪欓噷鐢ㄧ殑鏄?home/www/awstats
1 | mkdir -p /home/www/awstats
|
鎴戜滑鏉ュ啓涓涓剼鏈?/p>
鐒跺悗杈撳叆浠ヤ笅鍐呭
1 2 3 4 5 | #!/bin/bash
mkdir -p /home/www/awstats/akii.org
/usr/local/awstats/tools/awstats_buildstaticpages.pl -update \
-config=akii.org -lang=cn -dir=/home/www/awstats/akii.org \
-awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl
|
涓婅堪鍛戒護鐨勫叿浣撴剰鎬濆涓嬶細
- /usr/local/awstats/tools/awstats_buildstaticpages.pl Awstats 闈欐侀〉闈㈢敓鎴愬伐鍏?/li>
- -update -config=akii.org 鏇存柊閰嶇疆欏?/li>
- -lang=cn 璇█涓轟腑鏂?/li>
- -dir=/home/www/awstats 緇熻緇撴灉杈撳嚭鐩綍
- -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl Awstats 鏃ュ織鏇存柊紼嬪簭璺緞銆?/li>
鐒跺悗鍦ㄤ綘鐨刵ginx鐨勯厤緗枃浠朵腑錛屽湪浣犳兂瑕佸畨緗產wstats鎴栭粯璁ょ殑ip鎴栧煙鍚嶇殑server孌典腑錛屽姞鍏ュ叧浜巃wstats鍜宨con鐨勪袱涓洰褰曢厤緗?/p>
濡備竴涓畬鏁存渚嬶細
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | server {
listen 80;
server_name localhost;
root /home/www;
index index.html;
location ~ ^/awstats/ { # awstats 闈欐侀〉闈㈢洰褰?/code>
root /home/www/awstats;
autoindex on; #鍙互鐩綍嫻忚浣犵殑澶氫釜鍩熷悕鐨勭洰褰曠敤浜庡垎鏋?/code>
index index.html;
access_log off;
}
location ~ ^/icon/ { # 鍥炬爣鐩綍
root /usr/local/awstats/wwwroot;
index index.html;
access_log off;
}
}
|
鎺ヤ笅鏉ュ彲浠ユ祴璇曚竴涓嬭剼鏈槸鍚﹀彲浠ユ紜墽琛?/p>
榪樻槸鍒繕浜嗙粰瀹冨彲鎵ц鏉冮檺
1 2 | chmod +x /root/awstats.sh
/root/awstats.sh
|
濡傛灉浣犵湅鍒板畠鐢熸垚浜嗕竴鍫嗙綉欏碉紝閭e氨璇存槑鎴愬姛浜嗐?/p>
杈撳嚭淇℃伅閮ㄥ垎渚嬪
1 2 3 4 5 6 | Launch update process : "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=akii.org -update -configdir=
......
Build keywords page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=akii.org -staticlinks -lang=cn -output=keywords
Build errors404 page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=akii.org -staticlinks -lang=cn -output=errors404
20 files built.
Main HTML page is 'awstats.akii.org.html'.
|
鐒跺悗鍙互鎶婂畠鍔犲叆鑷姩榪愯浜嗐?/p>
閰嶇疆awstats鑴氭湰鑷姩榪愯
鍔犲叆
1 | 00 1 * * * /root/awstats.sh
|
鐒跺悗淇濆瓨閫鍑恒?/p>
榪欐牱灝卞彲浠ユ瘡澶╁湪鍑屾櫒鑷姩鍒嗗壊鏃ュ織錛屽茍涓斿紑濮嬭嚜鍔ㄧ敤awstats鍒嗘瀽nginx鐨勬棩蹇椾簡銆?/p>
璁よ瘉璁塊棶
濡傛灉浣犳兂緇欎綘鐨刟wstats鍔犱笂璁塊棶瀵嗙爜錛屽彲浠ヨ榪欓噷錛?a target="_blank">nginx涓虹洰褰曟垨緗戠珯鍔犱笂瀵嗙爜璁よ瘉
鍘熷垱鏂囩珷錛屽啓鐨勮緵鑻︺傚鏋滀綘瑕佽漿杞斤紝璇蜂繚鐣欏嚭澶勫強閾炬帴銆?/p>
鍙傝冭祫鏂?http://www.ibm.com/developerworks/cn/linux/l-cn-awstats-nginx/index.html