AWstatsのインストール
概要:AWstatsは高度なウェブ(ftpまたはmailも)サーバーアクセス統計をグラフィックで生成するフリーツールである。AWStatsを使用してApacheのアクセスログを解析し、Webサイトへのアクセス統計をWebブラウザから参照できるようにする。 1. AWStatsインストール # yum -y --enablerepo=rpmforge install awstats ← AWStatsインストール
========================================================================================== Package Arch Version Repository Size ========================================================================================== Installing: awstats noarch 6.95-1.el5.rf rpmforge 1.1 M Installing for dependencies: perl-Compress-Raw-Bzip2 i386 2.024-1.el5.rf rpmforge 108 k perl-Compress-Raw-Zlib i386 2.024-1.el5.rf rpmforge 169 k perl-HTML-Parser i386 3.55-1.fc6 base 92 k perl-HTML-Tagset noarch 3.10-2.1.1 base 15 k perl-IO-Compress noarch 2.024-1.el5.rf rpmforge 242 k perl-libwww-perl noarch 5.805-1.1.1 base 376 k Transaction Summary ========================================================================================== Install 7 Package(s) Update 0 Package(s) Remove 0 Package(s) 2. awstats.plの編集 レポートの日付形式を「月 2月 2010」から「2010年 2月」へ変更するためawstats.plを編集する。 # vi /var/www/awstats/awstats.pl ← awstats.pl編集
if ( $MonthRequired eq 'all' ) { print "$Message[6] $YearRequired"; } else { print #"$Message[5] $MonthNumLib{$MonthRequired} $YearRequired"; ← 行頭に#を追加してコメントアウト "$YearRequired$Message[6] ".$MonthNumLib{$MonthRequired}; ← 追加(日付をYYYY年 MM月形式にする) } print( $MonthRequired eq 'all' ? "$Message[6] $YearRequired" #: "$Message[5] " ← 行頭に#を追加してコメントアウト #. $MonthNumLib{$MonthRequired} ← 行頭に#を追加してコメントアウト #. " $YearRequired" ← 行頭に#を追加してコメントアウト : "$YearRequired$Message[6] $MonthNumLib{$MonthRequired}" ← 追加(日付をYYYY年 MM月形式にする) ); #print "$MonthNumLib{$monthix}<br />$YearRequired"; ← 行頭に#を追加してコメントアウト print "$YearRequired$Message[6]<br />$MonthNumLib{$monthix}"; ← 追加(日付をYYYY年 MM月形式にする) #print "$MonthNumLib{$monthix} $YearRequired"; ← 行頭に#を追加してコメントアウト print "$YearRequired$Message[6] $MonthNumLib{$monthix}"; ← 追加(日付をYYYY年 MM月形式にする) 3. AWStats設定 # rm -f /etc/awstats/awstats.localhost.localdomain.conf ← 不要な設定ファイルを削除する。 awstats設定ファイルを修正する。 # cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.centossrv.com.conf ← 設定ファイルをサンプルよりコピー # vi /etc/awstats/awstats.centossrv.com.conf ← 設定ファイル編集 # "SiteDomain" must contain the main domain name, or the main intranet web # server name, used to reach the web site. # If you share the same log file for several virtual web servers, this # parameter is used to tell AWStats to filter record that contains records for # this virtual host name only (So check that this virtual hostname can be # found in your log file and use a personalized log format that include the # %virtualname tag). # But for multi hosting a better solution is to have one log file for each # virtual web server. In this case, this parameter is only used to generate # full URL's links when ShowLinksOnUrl option is set to 1. # If analysing mail log, enter here the domain name of mail server. # Example: "myintranetserver" # Example: "www.domain.com" # Example: "ftp.domain.com" # Example: "domain.com" # SiteDomain="localhost.localdomain" ↓ SiteDomain="localhost.com" ← Webサーバー名を指定 # Enter here all other possible domain names, addresses or virtual host # aliases someone can use to access your site. Try to keep only the minimum # number of possible names/addresses to have the best performances. # You can repeat the "SiteDomain" value in this list. # This parameter is used to analyze referer field in log file and to help # AWStats to know if a referer URL is a local URL of same site or an URL of # another site. # Note: Use space between each value. # Note: You can use regular expression values writing value with REGEX[value]. # Note: You can also use @/mypath/myfile if list of aliases are in a file. # Example: "www.myserver.com localhost 127.0.0.1 REGEX[mydomain\.(net|org)$]" # HostAliases="localhost 127.0.0.1 REGEX[^192\.168\.1\.]" ← アクセス元から内部(例:192.168.1.X)を除外する # If you want to have hosts reported by name instead of ip address, AWStats # need to make reverse DNS lookups (if not already done in your log file). # With DNSLookup to 0, all hosts will be reported by their IP addresses and # not by the full hostname of visitors (except if names are already available # in log file). # If you want/need to set DNSLookup to 1, don't forget that this will reduce # dramatically AWStats update process speed. Do not use on large web sites. # Note: Reverse DNS lookup is done on IPv4 only (Enable ipv6 plugin for IPv6). # Note: Result of DNS Lookup can be used to build the Country report. However # it is highly recommanded to enable the plugin 'geoipfree' or 'geoip' to # have an accurate Country report with no need of DNS Lookup. # Possible values: # 0 - No DNS Lookup # 1 - DNS Lookup is fully enabled # 2 - DNS Lookup is made only from static DNS cache file (if it exists) # Default: 2 # DNSLookup=2 ↓ DNSLookup=1 ← アクセス元の名前解決を行う(アクセス元をIPアドレスではなくホスト名で表示する) # Plugin: GeoIPfree # Perl modules required: Geo::IPfree version 0.2+ (from Graciliano M.P.) # Country chart is built from an Internet IP-Country database. # This plugin is useless for intranet only log files. # Note: You must choose between using this plugin (need Perl Geo::IPfree # module, database less up to date) or the GeoIP plugin (need Perl Geo::IP # module from Maxmind, database more up to date). # Note: Activestate provide a corrupted version of Geo::IPfree 0.2 Perl # module, so install it from elsewhere (from www.cpan.org for example). # This plugin reduces AWStats speed of 10% ! # #LoadPlugin="geoipfree" ↓ LoadPlugin="geoipfree" ← コメント解除(アクセス元国情報を詳細に取得) 4. Geo-IPfreeのインストール # yum -y install perl-Geo-IPfree
← GeoIPfreeプラグイン動作に必要なPerlモジュールインストール
========================================================================================== Package Arch Version Repository Size ========================================================================================== Installing: perl-Geo-IPfree noarch 0.8-1.el5.rf rpmforge 408 k Transaction Summary ========================================================================================== Install 1 Package(s) Update 0 Package(s) Remove 0 Package(s) 5. 日本の検索エンジン対応 # vi /var/www/awstats/lib/search_engines.pm ← search_engines.pm編集
@SearchEnginesSearchIDOrder_list1=( 以下を追加 # Japanese Search Engines 'google\.co\.jp', '66\.249\.(89\.99|93\.104)', '66\.102\.(7\.99|7\.104|9\.104|11\.104)', '64\.233\.(161\.104|179\.104|167\.104|183\.104|187\.104)', '72\.14\.(203|205|207|209|221|235|253)\.104', '216\.239\.(37\.104|39\.104|41\.104|51\.104|57\.104|59\.104)', 'search\.biglobe\.ne\.jp', 'goo\.ne\.jp', 'nifty\.com', 'search\.msn\.co\.jp', 'search\.odn\.ne\.jp', 'excite\.ne\.jp', 'naver\.co\.jp', 'fresheye\.com', 'tocc\.co\.jp', 'infoseek\.co\.jp', 'cache\.yahoofs\.jp', 'search\.livedoor\.com', 'www\.ceek\.jp', 'www\.bing\.com', 's\.luna\.tv', '72\.14\.207\.99', '209\.85\.165\.104', '209\.85\.129\.104', '209\.85\.129\.132', '209\.85\.(173|175)\.104', '74\.125\.47\.132', '74\.125\.77\.132', '74\.125\.95\.132', '74\.125\.153\.132', '74\.125\.155\.132', '72\.14\.235\.132', '66\.249\.89\.104', %NotSearchEnginesKeys=( 以下を追加 # For Japanese Search Engines 'infoseek\.co\.jp'=>'at\.infoseek\.co\.jp', 'goo\.ne\.jp'=>'members\.goo\.ne\.jp', %SearchEnginesHashID = ( 以下を追加 # Japanese Search Engines 'google\.co\.jp','googlejapan', '66\.249\.(89\.99|93\.104)','googlejapan', '66\.102\.(7\.99|7\.104|9\.104|11\.104)','googlejapan', '64\.233\.(161\.104|179\.104|167\.104|183\.104|187\.104)','googlejapan', '72\.14\.(203|205|207|209|221|235|253)\.104','googlejapan', '216\.239\.(37\.104|39\.104|41\.104|51\.104|57\.104|59\.104)','googlejapan', 'search\.biglobe\.ne\.jp','biglobe', 'goo\.ne\.jp','goo', 'nifty\.com','nifty', 'search\.msn\.co\.jp','msnjapan', 'search\.odn\.ne\.jp','odn', 'excite\.co\.jp','excitejapan', 'naver\.co\.jp','naver', 'fresheye\.com','fresheye', 'tocc\.co\.jp','tocc', 'infoseek\.co\.jp','infoseek', 'cache\.yahoofs\.jp','yahoocache', 'search\.livedoor\.com','livedoor', 'www\.ceek\.jp','ceek', 'www\.bing\.com','bing', 's\.luna\.tv','lunascape', '72\.14\.207\.99','googlejapan', '209\.85\.165\.104','googlejapan', '209\.85\.129\.104','googlejapan', '209\.85\.129\.132','googlejapan', '209\.85\.(173|175)\.104','googlejapan', '74\.125\.47\.132','googlejapan', '74\.125\.77\.132','googlejapan', '74\.125\.95\.132','googlejapan', '74\.125\.153\.132','googlejapan', '74\.125\.155\.132','googlejapan', '72\.14\.235\.132','googlejapan', '66\.249\.89\.104','googlejapan', %SearchEnginesKnownUrl=( 以下を追加 # Japanese Search Engines 'googlejapan','(p|q)=', 'biglobe','q=', 'goo','MT=', 'nifty','Text=', 'msnjapan','(q|MT)=', 'odn','Querystring=', 'excitejapan','search=', 'naver','query=', 'fresheye','kw=', 'tocc','QRY=', 'infoseek','qt=', 'yahoocache','w=', 'livedoor','q=', 'ceek','q=', 'clusty','query=', @WordsToCleanSearchUrl= ('act=','annuaire=','btng=','cat=','categoria=','cfg=','cof=','cou =','count=','cp=','dd=','domain=','dt=','dw=','enc=','exec=','geo=','hc=','height=','hits= ','hl=','hq=','hs=','id=','kl=','lang=','loc=','lr=','matchmode=','medor=','message=','met a=','mode=','order=','page=','par=','pays=','pg=','pos=','prg=','qc=','refer=','sa=','safe =','sc=','sort=','src=','start=','style=','stype=','sum=','tag=','temp=','theme=','type=', 'url=','user=','width=','what=','\\.x=','\\.y=','y=','look='); ↓ 変更 @WordsToCleanSearchUrl= ('act=','annuaire=','btng=','cat=','categoria=','cfg=','cof=','cou =','count=','cp=','dd=','domain=','dt=','dw=','enc=','exec=','geo=','hc=','height=','hits= ','hl=','hq=','hs=','id=','kl=','lang=','loc=','lr=','matchmode=','medor=','message=','met a=','mode=','order=','page=','par=','pays=','pg=','pos=','prg=','qc=','refer=','sa=','safe =','sc=','sort=','src=','start=','style=','stype=','sum=','tag=','temp=','theme=','type=', 'url=','user=','width=','what=','\\.x=','\\.y=','y=','look=','target=','collection=','show Summary=','perPage=','next=','DB=','OPE=','Max=','base=','submit=','SearchType=','SESSIONI D=','QUERYRULE=','DISPLAYMIN=','RELURLSWITCH=','SORT=','start=','direct=','relwd=','lk=',' svx=','nh=','internet=','DC=','submit0=','DEST=','where=','CCM=','NRS=','UNI=','UD0=','FRS =','sv=','rf=','oq=','col=','act\.search='); %SearchEnginesHashLib=( 以下を追加 # Japanese Search Engines 'googlejapan','Google Japan', 'biglobe','Biglobe', 'goo','Goo', 'nifty','Nifty', 'msnjapan','MSN Japan', 'odn','ODN', 'excitejapan','Excite Japan', 'naver','Naver', 'fresheye','Fresheye', 'tocc','TOCC/Search', 'infoseek','Infoseek', 'yahoocache','Yahoo Cache', 'livedoor','Livedoor', 'ceek','CEEK.JP', 'bing','Bing', 'lunascape','Lunascape', 6. Apache設定 # vi /etc/httpd/conf.d/awstats.conf ← Apache用AWStats設定ファイル編集
<Directory /var/www/awstats/> DirectoryIndex awstats.pl Options ExecCGI order deny,allow deny from all allow from all ← 追加 #allow from 127.0.0.1 ← コメントアウト </Directory> # /etc/rc.d/init.d/httpd reload ← Apache設定再読込み httpd を再読み込み中: [ OK ] 7. AWStatsデータベース作成
8. Apacheログローテーション設定 # vi /etc/logrotate.d/httpd ← Apacheログロテート設定ファイル編集
/var/log/httpd/*log { missingok notifempty sharedscripts -------------追加(ここから)------------- prerotate `rpm -ql awstats|grep "awstats_updateall\.pl"` now -confdir="/etc/awstats" \ -awstatsprog="`rpm -ql awstats|grep "awstats\.pl"`" >/dev/null endscript -------------追加(ここまで)------------- postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true endscript } 9. AWStats確認 10. アクセス統計ページHTML版の作成
Last-modified: 2014-03-11 (火) 01:59:57 (3700d)
|