AWStats

apache ¤Î¥¢¥¯¥»¥¹²òÀÏ¥½¥Õ¥È

AWStats¤Ï¡¢httpd¤Î¥¢¥¯¥»¥¹¥í¥°¤ò²òÀϤ·¡¢»ë³ÐŪ¤Ë¥Ö¥é¥¦¥¶¤Ç±ÜÍ÷¤¹¤ë¤³¤È¤¬½ÐÍè¤ë·Á¤ËÀ°·Á¤¹¤ëPerl¤Î¥¹¥¯¥ê¥×¥È

¡¡Ëܲȥµ¥¤¥È¡¡http://awstats.sourceforge.net/
¡¡¡¡2006-04-07¸½ºß ºÇ¿·°ÂÄêÈÄ¡¡ver6.5

¡¡´°Á´ÆüËܸìÈÇ¡¡http://www.bflets.dyndns.org/Tools/AWStatsJpn.html
¡¡¡¡2006-04-07¸½ºß ver6.5

¡¡´°Á´ÆüËܸìÈÇ¡¡http://www.starplatinum.jp/awstats/awstats66/
¡¡¡¡2011-01-20¸½ºß ver6.6

¡¡´°Á´ÆüËܸìÈÇ¡¡http://www.starplatinum.jp/awstats/awstats70/
¡¡¡¡2011-03-28¸½ºß ver7.0

¡¡ËܲȡÖAWStats¡×¤âVer.4.0¤«¤éÀµ¼°¤ËÆüËܸì¤ËÂбþ¤·¤¿¤³¤È¤Ë¤Ê¤Ã¤Æ¤ë¤¬¡¢Èó¾ï¤Ë¤ªÁÆËö¡£
¡¡¤è¤ê´°àú¤ÊÆüËܸìÂбþ¤òÌܻؤ·¤Æ½¤Àµ¤ò¹Ô¤Ã¤¿¤â¤Î¤ò¸ø³«¤·¤Æ¤¤¤ë¤¹¤Ð¤é¤·¤¤¿Í¤¬¤¤¤¿¤Î¤Ç¡¢»È¤»¤Æ¤¤¤¿¤À¤¯¡£

»öÁ°½àÈ÷

Jcode.pm ¤Î¥¤¥ó¥¹¥È¡¼¥ë

¡¡¥ª¥ê¥¸¥Ê¥ë¥í¥°Æâ¤ÎURL¤ò¥Ç¥³¡¼¥É¤¹¤ë¤¿¤á¤ËɬÍ×

¡¡»²¾È
¡¡http://openlab.jp/Jcode/index-j.html
¡¡http://www.mytools.net/memo/JcodePM.html

¡¡¡ÖJcode-0.xx.tar.gz¡×¤ò¥À¥¦¥ó¥í¡¼¥É
¡¡http://www.ring.gr.jp/pub/lang/perl/CPAN/modules/by-module/Encode/DANKOGAI/

¡¡¥¤¥ó¥¹¥È¡¼¥ë

# tar zxvf Jcode-0.88.tar.gz
# cd Jcode-0.88
# perl Makefile.PL; make; make install

Can't locate ExtUtils/MakeMaker.pm ¤Ê¤É¤ÈÅܤé¤ì¤¿¤é

# yum install perl-ExtUtils-MakeMaker

¡¡³Îǧ

# perl -MJcode -e'print $Jcode::VERSION'
0.88

¡¡ºï½ü

# rm -rf Jcode-0.88
# rm -f Jcode-0.88.tar.gz

nkf¥¤¥ó¥¹¥È¡¼¥ë

¡¡¡Önkf207.tar.gz¡×¤ò¥À¥¦¥ó¥í¡¼¥É
¡¡http://sourceforge.jp/projects/nkf/

¡¡¥¤¥ó¥¹¥È¡¼¥ë

# yum install nkf

OR

# tar zxvf nkf207.tar.gz
# cd nkf207
# make
# cp nkf /usr/bin/

¡¡ºï½ü

# rm -rf nkf207
# rm -f nkf207.tar.gz

¥ï¡¼¥à¤¬»Ä¤¹¥í¥°¤Ë¤è¤ëAWStats¤Î¥¨¥é¡¼²óÈò

AWStats¤Ê¤É¤Ç¥¢¥¯¥»¥¹¥í¥°¤ò¸µ¤ËÅý·×¾ðÊó¤ò½ÐÎϤ·¤Æ¤¤¤ë¾ì¹ç¡¢
¥ï¡¼¥à¤Î»Ä¤¹¥¢¥¯¥»¥¹¥í¥°¤¬¸¶°ø¤Ç¥¨¥é¡¼¤È¤Ê¤ê¡¢¼Â¹Ô¤Ç¤­¤Ê¤¯¤Ê¤ë¾ì¹ç¤¬¤¢¤ë¡£
¤³¤ì¤é¤ÎÂкö¤È¤·¤Æ¡¢http.conf¤òÊÔ½¸¤·¤Þ¤¹¡£ ¾ÜºÙ¤ÏApache2¥¢¥¯¥»¥¹¥í¥°¤Î¥«¥¹¥¿¥Þ¥¤¥º¤ò»²¾È¡£
²èÁüÅù¤Î¥í¥°ÇÓ½ü¤ÎÀßÄê¤ÏÉÔÍ×

´Ä¶­³Îǧ

  • perl¤Î¥Ð¡¼¥¸¥ç¥ó¤¬5.8.0°Ê¹ß¤Ç¤¢¤ë
    # perl -v
    This is perl, v5.8.5 built for i386-linux-thread-multi
  • perl¤Î¾ì½ê
    # which perl
    /usr/bin/perl
  • WWW¥µ¡¼¥Ð¤ÎCGI¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Ñ¥¹
    ¡¡ËÜʸ¤Ç¤Ï¡¡/usr/local/apache2/cgi-bin¡¡¤È¤¹¤ë
  • Apache¤Î¥¢¥¯¥»¥¹¥í¥°¤Î¥Ñ¥¹
    ¡¡ËÜʸ¤Ç¤Ï¡¡/usr/local/apache2/logs/www.hoge.jp-access_log¡¡¤È¤¹¤ë
  • WWW¥µ¡¼¥Ð¤Î¥ë¡¼¥È¥Ç¥£¥ì¥¯¥È¥ê
    ¡¡ËÜʸ¤Ç¤Ï¡¡/home/hoge/public_html¡¡¤È¤¹¤ë
  • Apache¤Î¥í¥°¥Õ¥©¡¼¥Þ¥Ã¥È¤¬combined¤Ç¤¢¤ë
    # vi /usr/local/apache2/conf/httpd.conf
    ¡¡httpd.conf
    CustomLog /usr/local/apache2/logs/www.hoge.jp-access_log combined

AWStats 6.5´°Á´ÆüËܸìÈÇ¡¡¥¤¥ó¥¹¥È¡¼¥ë

¡¡»²¹Í
¡¡http://www.akenotori.jp/soft/26.html#SEC9
¡¡http://cyberam.dip.jp/linux_server/log/awstats60_main.html
¡¡http://honana.com/awstats

¥¤¥ó¥¹¥È¡¼¥ë

¥Ç¥£¥ì¥¯¥È¥ê¤ÎºîÀ®

// AWStats¥¤¥ó¥¹¥È¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê
# mkdir /usr/local/apache2/cgi-bin/awstats
// ¥í¥°¥Ç¥£¥ì¥¯¥È¥ê
# mkdir /usr/local/apache2/cgi-bin/awstats/logs
// ¥Ç¡¼¥¿¥Ç¥£¥ì¥¯¥È¥ê
# mkdir /usr/local/apache2/cgi-bin/awstats/data
// ¥¤¥á¡¼¥¸¥Õ¥¡¥¤¥ë¥Ç¥£¥ì¥¯¥È¥ê
# mkdir -p /usr/local/apache2/htdocs/images/awstats

¥¤¥ó¥¹¥È¡¼¥ë

# tar zxvf AWStats65_Jpn.tar.gz
# cd AWStats65_Jpn
# cd /usr/local/src/AWStats65_Jpn/wwwroot/
# cp -rf cgi-bin/* /usr/local/apache2/cgi-bin/awstats/
# cp -rf icon/* /usr/local/apache2/htdocs/images/awstats/

ÀßÄê

# cd /usr/local/apache2/cgi-bin/awstats/
# nkf -ed awstats.model_jp.conf > awstats.www.hoge.jp.conf
# vi awstats.www.hoge.jp.conf

awstats.www.hoge.jp.conf

LogFile="/usr/local/apache2/cgi-bin/awstats/logs/www.hoge.jp-access_log.utf8"
SiteDomain="www.hoge.jp"
HostAliases="localhost 127.0.0.1 REGEX[hoge\.jp$]"
DNSLookup=1
DirData="/usr/local/apache2/cgi-bin/awstats/data"
DirCgi="/cgi-bin/awstats"
DirIcons="/images/awstats"
DetailedReportsOnNewWindows=0
SkipHosts="REGEX[^192\.168\.0\.]"  # ÆÃÄê¤Î¥Û¥¹¥È¤ò½ü¤¯
SkipFiles="REGEX[^\/program.php]"   # ÆÃÄê¤Î¥Õ¥¡¥¤¥ë¤ò½ü¤¯

¼êÆ°¤Ç¼Â¹Ô

¥í¥°¥Õ¥¡¥¤¥ëºîÀ®

# /usr/local/apache2/cgi-bin/awstats/utf8_decode.pl ¡¡</usr/local/apache2/logs/www.hoge.jp-access_log >  /usr/local/apache2/cgi-bin/awstats/logs/www.hoge.jp-access_log.utf8

¥¢¥¯¥»¥¹²òÀϼ¹Ô

# cd /usr/local/apache2/cgi-bin/awstats
# ./awstats.pl -config=www.hoge.jp -update

Àµ¾ï¤Ë½ªÎ»¤·¤Æ¤¤¤ì¤Ð¡¢½èÍý·ë²Ì¤¬°Ê²¼¤Î¤è¤¦¤Ê·Á¤Çɽ¼¨¤µ¤ì¤Þ¤¹¡£

Lines in file: 225730
Found 5 dropped records,
Found 124 corrupted records,
Found 0 old records,
Found 225601 new records.

²èÁü¤òɽ¼¨¤Ç¤­¤ë¤è¤¦ httpd.conf ¤Ë²¼µ­¤òÄɵ­

# vi /usr/local/apache2/conf/httpd.conf
Alias /images/awstats/ "/usr/local/apache2/htdocs/images/awstats/"

¥Ö¥é¥¦¥¶¤Ç¥¢¥¯¥»¥¹²òÀÏ¥Õ¥¡¥¤¥ë¤Ë¥¢¥¯¥»¥¹¤·¤Æ¤ß¤ë ¡¡http://www.hoge.jp/awstats/

Äê´üŪ¤Ë¼Â¹Ô

# cd /usr/local/src/AWStats65_Jpn/
# nkf -ed awstats.cron > /usr/local/apache2/cgi-bin/awstats/awstats.cron

awstats.cron

#! /usr/bin/perl

# ´°Á´ÆüËܸìÈÇAWStatsÍÑ¥µ¥ó¥×¥ëcron¥Õ¥¡¥¤¥ë
#
# ¥Õ¥¡¥¤¥ë¥Ñ¥¹Åù¤Ï¼«Ê¬¤Î´Ä¶­¤Ë¹ç¤ï¤»¤Æ½ñ¤­Ä¾¤·¤Æ²¼¤µ¤¤¡£

# http¤Î¥í¥°¥Õ¥¡¥¤¥ë¤ò¥Ç¥³¡¼¥É¤·¤¿¾å¤Ç°ì»þ¥Ç¥£¥ì¥¯¥È¥ê¤Ë³ÊǼ¤·¤Þ¤¹¡£
# access_log.utf8¤Ï°ì»þŪ¤Ë¥Ç¥³¡¼¥É¤·¤¿¥í¥°¤òÊݸ¤¹¤ë¥Õ¥¡¥¤¥ë¤Î̾Á°¤Ç¤¹¡£

system("/usr/local/apache2/cgi-bin/awstats/utf8_decode.pl <  /usr/local/apache2/logs/www.hoge.jp-access_log >  /usr/local/apache2/cgi-bin/awstats/logs/www.hoge.jp-access_log.utf8");

# ¥í¥°¥Õ¥¡¥¤¥ë¤¬Ê£¿ô¤Î¾ì¹ç¡¢¥Õ¥¡¥¤¥ë¿ô¤Îʬ¹Ô¤¦
#system("/usr/local/apache2/cgi-bin/awstats/utf8_decode.pl < /usr/local/apache2/logs/www.hoge.jp-ssl_access_log >     #/usr/local/apache2/cgi-bin/awstats/logs/www.hoge.jp-access_log.utf8");

# awstats.pl¤¬ÀÚ¤êµÍ¤á¤Ê¤¤¥ª¥ê¥¸¥Ê¥ë¤Î¥í¥°¤òÀÚ¤êµÍ¤á¤Þ¤¹¡£
#open(LOG,"+</usr/local/apache2/logs/www.hoge.jp-access_log");
#truncate(LOG,0);
#close(LOG);

#open(LOG,"+</usr/local/apache2/logs/www.hoge.jp-ssl_access_log");
#truncate(LOG,0);
#close(LOG);

# Ver.5.0¤«¤é¡¢¹¹¿·½èÍý¤òÊÌÅÓÁö¤é¤»¤ëɬÍפ¬¤Ç¤­¤¿¤é¤·¤¤....
system("/usr/local/apache2/cgi-bin/awstats/awstats.pl -config=www.hoge.jp -update > /dev/null");

# awstats.pl¤òÁö¤é¤»¡¢html¥Õ¥¡¥¤¥ë¤ò½ÐÎϤ·¤Þ¤¹¡£
# ɬ¿Ü¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¤¬¡¢awstats.pl¤òľÀÜ»²¾È¤µ¤»¤ë¤è¤ê¤â¡¢html¤Ë½ÐÎϤ·¤Æɽ¼¨¤¹
# ¤ëÊý¤¬¡¢Îɹ¥¤Ê¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤¬ÆÀ¤é¤ì¤Þ¤¹¡£
#system("/usr/local/apache2/cgi-bin/awstats/awstats.pl -config=www.hoge.jp -output -staticlink > /home/hoge/public_html/awstats/index.html");

# ¥¢¥¯¥»¥¹²Äǽ¤Ë¤Ê¤ë¤è¤¦¤Ë½ÐÎϤ·¤¿html¥Õ¥¡¥¤¥ë¤Î¸¢¸Â¤òÊѹ¹
#system("chgrp hoge /home/hoge/public_html/awstats/index.html");
#system("chown hoge /home/hoge/public_html/awstats/index.html");

¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤òÊѹ¹

# chmod 700 /usr/local/apache2/cgi-bin/awstats/awstats.cron

cron ¤Ç¤³¤Î¥¹¥¯¥ê¥×¥È¤ò¼«Æ°¼Â¹Ô ¡ÊÎã¤Ç¤Ï30ʬËè¤Ë¼Â¹Ô¡Ë

# crontab -e
30 * * * * perl /usr/local/apache2/cgi-bin/awstats/awstats.cron

AWStats¤Èlogrotate¤ÎÌäÂêÅÀ²ò·è

Apache¤Îaccess_log¤òlogrotate¤Ë¤è¤ê¥í¡¼¥Æ¡¼¥·¥ç¥ó¤·¤Æ¤¤¤ë¾ì¹ç¤ËÌäÂ꤬ȯÀ¸¤¹¤ë¡£

Î㤨¤Ð4»þ10ʬ¤Ëaccess_log¤Î ¥í¥°¥í¡¼¥Æ¡¼¥·¥ç¥ó¤¬¹Ô¤ï¤ì¤ë¤È¤¹¤ë¤È
¡ÖÄê´üŪ¤Ë¼Â¹Ô¤¹¤ë¡×¤Ç¾Ò²ð¤·¤¿¥¹¥¯¥ê¥×¥È¤Ï30ʬ¤ª¤­¤Ë¼Â¹Ô¤µ¤ì¤ë¤Î¤Ç
4»þ¤Ë¼Â¹Ô¤µ¤ì¤¿¤È¤·¤Æ¼¡¤Ë¼Â¹Ô¤µ¤ì¤ë¤Î¤Ï4»þ30ʬ¤Ç¤¢¤ë¤¿¤á¡¢
4»þ¤«¤é4»þ10ʬ¤Î´Ö¤Ëaccess_log¤Ëµ­Ï¿¤µ¤ì¤¿¥í¥°¤Ïawstats¤ÎÅý·×¾ðÊó¤ËÈ¿±Ç¤µ¤ì¤Ê¤¤¡£

¤³¤ÎÌäÂê¤ò²ò·è¤¹¤ë¤Ë¤Ïaccess_log¤ò¥í¡¼¥Æ¡¼¥·¥ç¥ó¤¹¤ëľÁ°¤Ëawstats.pl¤Ë¤è¤êÅý·×¾ðÊó¤ò¥¢¥Ã¥×¥Ç¡¼¥È¤·¤Þ¤¹¡£

/etc/logrotate.d/apache¤òÊÔ½¸¤·¤Þ¤¹¡£

# vi /etc/logrotate.d/apache

²¼µ­¤òapacheºÆµ¯Æ°¤ÎÁ°¤ËÄɲÃ

prerotate
perl /usr/local/apache2/cgi-bin/awstats/awstats.cron
endscript
"/usr/local/apache2/logs/*_log"
{
  rotate 4
  compress
  weekly
  sharedscripts
  prerotate
  perl /usr/local/apache2/cgi-bin/awstats/awstats.cron
  endscript
  postrotate
  /usr/local/apache2/bin/apachectl restart
  endscript
}

ÀÅŪHTML½ÐÎÏ

cgi¤¬½Å¤¤¤Î¤Ç¤¢¤ì¤ÐHTML½ÐÎÏ¡£
¢¨¸½ºß·î¤Îʬ¤·¤«HTML¤ÏºîÀ®¤µ¤ì¤Ê¤¤¡£²áµî¤Î·î¤Î±ÜÍ÷¤Ïcgi¡£
¢¨¸ø³«¤·¤¿¤¯¤Ê¤¤¾ì¹ç¤ÏÂкö¤¬É¬Íס£¡Êcgi¤ÏÀßÄê¤ÇIP¤Ê¤É¤Î±ÜÍ÷À©¸Â¤ò¤«¤±¤é¤ì¤ë¡Ë

¼êÆ°¼Â¹Ô

# ./awstats.pl -config=www.hoge.jp -output -staticlink > /home/hoge/public_html/awstats/index.html

¥¯¥í¡¼¥ó¤ÇÆ°¤«¤¹¾ì¹ç¤Ïawstats.cron¤ËÄɵ­

# awstats.pl¤òÁö¤é¤»¡¢html¥Õ¥¡¥¤¥ë¤ò½ÐÎϤ·¤Þ¤¹¡£
# ɬ¿Ü¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¤¬¡¢awstats.pl¤òľÀÜ»²¾È¤µ¤»¤ë¤è¤ê¤â¡¢html¤Ë½ÐÎϤ·¤Æɽ¼¨¤¹
# ¤ëÊý¤¬¡¢Îɹ¥¤Ê¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤¬ÆÀ¤é¤ì¤Þ¤¹¡£
system("/usr/local/apache2/cgi-bin/awstats/awstats.pl -config=www.hoge.jp -output -staticlink > /home/hoge/public_html/awstats/index.html");

# ¥¢¥¯¥»¥¹²Äǽ¤Ë¤Ê¤ë¤è¤¦¤Ë½ÐÎϤ·¤¿html¥Õ¥¡¥¤¥ë¤Î¸¢¸Â¤òÊѹ¹
system("chgrp hoge /home/hoge/public_html/awstats/index.html");
system("chown hoge /home/hoge/public_html/awstats/index.html");

¥È¥Ã¥×   ÊÔ½¸ Åà·ë º¹Ê¬ ¥Ð¥Ã¥¯¥¢¥Ã¥× źÉÕ Ê£À½ ̾Á°Êѹ¹ ¥ê¥í¡¼¥É   ¿·µ¬ °ìÍ÷ ¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS
Last-modified: 2021-09-19 (Æü) 19:09:15