アクセスログ解析ツール AWstats をインストールします。
1. AWstats インストール
RPMforgeからインストール
1 |
# yum --enablerepo=rpmforge -y install awstats |
サンプルのconfファイルを自サイト用にコピーします。
1 |
# cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.network-learning.conf |
2. 設定ファイルの編集
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# vi /etc/awstats/awstats.network-learning.conf 115 # Examples for Apache combined logs (following two examples are equivalent): 116 # LogFormat = 1 117 # LogFormat = "%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot" 118 # 119 # Example for IIS: 120 # LogFormat = 2 121 # 122 LogFormat=1 123 // 122行目:変更 // Apache のログフォーマットが"combined"の場合は「1」 // "common"の場合は「4」( ただしこの場合ブラウザ情報等、一部の解析はできなくなる) 137 # "SiteDomain" must contain the main domain name, or the main intranet web 138 # server name, used to reach the web site. 139 # If you share the same log file for several virtual web servers, this 140 # parameter is used to tell AWStats to filter record that contains records for 141 # this virtual host name only (So check that this virtual hostname can be 142 # found in your log file and use a personalized log format that include the 143 # %virtualname tag). 144 # But for multi hosting a better solution is to have one log file for each 145 # virtual web server. In this case, this parameter is only used to generate 146 # full URL's links when ShowLinksOnUrl option is set to 1. 147 # If analyzing mail log, enter here the domain name of mail server. 148 # Example: "myintranetserver" 149 # Example: "www.domain.com" 150 # Example: "ftp.domain.com" 151 # Example: "domain.com" 152 # 153 SiteDomain="www.network-learning.net" 154 // 153行目:サイト名をFQDNで指定します。 156 # Enter here all other possible domain names, addresses or virtual host 157 # aliases someone can use to access your site. Try to keep only the minimum 158 # number of possible names/addresses to have the best performances. 159 # You can repeat the "SiteDomain" value in this list. 160 # This parameter is used to analyze referer field in log file and to help 161 # AWStats to know if a referer URL is a local URL of same site or an URL of 162 # another site. 163 # Note: Use space between each value. 164 # Note: You can use regular expression values writing value with REGEX[value]. 165 # Note: You can also use @/mypath/myfile if list of aliases are in a file. 166 # Example: "www.myserver.com localhost 127.0.0.1 REGEX[mydomain\.(net|org)$]" 167 # 168 HostAliases="localhost 127.0.0.1 REGEX[mydomain\.] REGEX[^192\.168\.21\.]" // 168行目:除外するドメイン名/IPアドレス追記 898 # Set your primary language (ISO-639-1 language codes). 899 # Possible values: 900 # Albanian=al, Bosnian=ba, Bulgarian=bg, Catalan=ca, 901 # Chinese (Taiwan)=tw, Chinese (Simpliefied)=cn, Croatian=hr, Czech=cz, 902 # Danish=dk, Dutch=nl, English=en, Estonian=et, Euskara=eu, Finnish=fi, 903 # French=fr, Galician=gl, German=de, Greek=gr, Hebrew=he, Hungarian=hu, 904 # Icelandic=is, Indonesian=id, Italian=it, Japanese=jp, Korean=ko, 905 # Latvian=lv, Norwegian (Nynorsk)=nn, Norwegian (Bokmal)=nb, Polish=pl, 906 # Portuguese=pt, Portuguese (Brazilian)=br, Romanian=ro, Russian=ru, 907 # Serbian=sr, Slovak=sk, Slovenian=si, Spanish=es, Swedish=se, Turkish=tr, 908 # Ukrainian=ua, Welsh=cy. 909 # First available language accepted by browser=auto 910 # Default: "auto" 911 # 912 Lang="jp" // 912行目:日本語に変更 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# vi /etc/httpd/conf.d/awstats.conf 1 Alias /awstats/icon/ /var/www/awstats/icon/ 2 3 Alias /report /var/www/awstats/ 4 ScriptAlias /awstats/ /var/www/awstats/ 5 <Directory "/var/www/awstats"> 6 DirectoryIndex awstats.pl 7 Options ExecCGI 8 order deny,allow 9 deny from all 10 allow from 127.0.0.1 192.168.21.0/24 11 </Directory> 12 13 #Alias /css/ /var/www/awstats/css/ 14 #Alias /js/ /var/www/awstats/js/ // 3行目:Aliasを追加 // 10行目:アクセス許可IP追記 |
3. Apacheの再起動
1 2 3 |
# /etc/rc.d/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] |
4. レポート出力
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# /var/www/awstats/awstats.pl -config=network-learning -update Create/Update database for config "/etc/awstats/awstats.network-learning.conf" by AWStats version 7.1 (build 1.983) From data in log file "/var/log/httpd/access_log"... Phase 1 : First bypass old records, searching new record... Searching new records from beginning of log file... Phase 2 : Now process new records (Flush history on disk after 20000 hosts)... Jumped lines in file: 0 Parsed lines in file: 12063 Found 29 dropped records, Found 0 comments, Found 0 blank records, Found 0 corrupted records, Found 0 old records, Found 12034 new qualified records. |
5. 出力したレポートをHTMLにする
1 |
# /var/www/awstats/awstats.pl -config=network-learning -output -staticlink > /var/www/awstats/index.html |
6. cronの内容を変更しておく
1 2 3 4 5 6 7 8 9 10 11 12 13 |
4行目:exec行をコメント化する 5/6行目に追加 ※変更が自動でされる時があります。 # vi /etc/cron.hourly/00awstats 1 #!/bin/bash 2 3 if [ -f /var/log/httpd/access_log ] ; then 4 # exec /usr/bin/awstats_updateall.pl now -confdir="/etc" -awstatsprog="/var/www/awstats/awstats.pl" > /dev/null 5 /var/www/awstats/awstats.pl -config=www.network.learning -update > /dev/null 6 /var/www/awstats/awstats.pl -config=www.network.learning -output -staticlink > /var/www/awstats/index.html 7 fi 8 exit 0 |
7. 「http://(サーバーのホスト名またはIPアドレス/)/report/index.html」にアクセスすると、 以下のような画面が表示されApacheのログを見ることができます。