Webalizer 보다 깔끔한 웹 서버 로그분석기인 AWStats 을 설치 하는 방법이다.
아래의 홈페이지에서 최신 Stable 버전을 받자.

http://awstats.sourceforge.net/#DOWNLOAD

AWStats 설치
awstats/tools 디렉토리에 있는 awstats_configure.pl 를 이용하여 설치를 진행하며 파란색 부분을 유심히 보길 바란다.

[root@ruo91 ~]# wget http://prdownloads.sourceforge.net/awstats/awstats-6.9.tar.gz
[root@ruo91 ~]# tar xzvf awstats-6.9.tar.gz
[root@ruo91 ~]# mv awstats-6.9 /usr/local/awstats
[root@ruo91 ~]# chmod 755 /usr/local/awstats
[root@ruo91 ~]# cd /usr/local/awstats/tools
[root@ruo91 ~]# ./awstats_configure.pl

아파치의 httpd.conf 설정 파일을 지정 해주면 된다. AWstats 에서는 httpd.conf 내용 중 로그 방식이
common 으로 되어 있으면 경고 메세지가 나오며 combined 방식으로 로그가 설정 되어야만 경고 메세지가 뜨질 않는다.

—– AWStats awstats_configure 1.0 (build 1.8) (c) Laurent Destailleur —–
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
– You are not an administrator user,
– You want to analyze downloaded log files without web server,
– You want to analyze mail or ftp log files instead of web log files,
– You need to analyze load balanced servers log files,
– You want to ‘understand’ all possible ways to use AWStats…
Read the AWStats documentation (docs/index.html).

—–> 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):
> /usr/local/apache2/conf/httpd.conf

새로운 프로파일을 생성할지 물어본다. y 를 눌러 새로 생성해주자.

—–> Check and complete web server config file ‘/usr/local/apache2/conf/httpd.conf’
Add ‘Alias /awstatsclasses “/usr/local/awstats/wwwroot/classes/”‘
Add ‘Alias /awstatscss “/usr/local/awstats/wwwroot/css/”‘
Add ‘Alias /awstatsicons “/usr/local/awstats/wwwroot/icon/”‘
Add ‘ScriptAlias /awstats/ “/usr/local/awstats/wwwroot/cgi-bin/”‘
Add ‘<Directory>’ directive
AWStats directives added to Apache config file.

—–> 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] ? y

새로 생성한 프로파일 이름을 지정 해준다.

만약 ruo91 이라고 지정 해줬다면 awstats.ruo91.conf 파일로 생성 된다.
(도메인으로 입력 했다면 awstats.www.yongbok.net.conf 로 생성 된다.)

—–> 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:
> www.yongbok.net

config 파일이 저장될 디렉토리를 지정 해준다. 기본값은 /etc/awstats 이다.

—–> 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

새로운 프로파일이 생성 되었으며 엔터를 눌러 설치를 완료 한다.

—–> Create config file ‘/etc/awstats/awstats.www.yongbok.net.conf’
Config file /etc/awstats/awstats.www.yongbok.net.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=www.yongbok.net
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…

A SIMPLE config file has been created: /etc/awstats/awstats.www.yongbok.net.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for ‘www.yongbok.net’ with command:
> perl awstats.pl -update -config=www.yongbok.net
You can also read your statistics for ‘www.yongbok.net’ with URL:
> http://localhost/awstats/awstats.pl?config=www.yongbok.net

Press ENTER to finish…

생성된 프로파일을 수정 해준다.

[root@ruo91 ~]# cd /etc/awstats
[root@ruo91 ~]# vi /etc/awstats/awstats.www.yongbok.net.conf
# 로그 파일 지정
# 기본값 LogFile=”/var/log/httpd/mylog.log”
# 필자는 아파치의 logrotate 를 사용하여 로그를 분리하므로 아래와 같이 설정 해줌
LogFile=”/home/apache2-log/www/www-access-%YYYY-%MM-%DD.log”
#
# 언어 설정 (기본값 auto)
# 한글로 사용 가능 하도록 ko 로 변경
Lang=”ko”

/var/lib 디렉토리에 awstats 하위 디렉토리를 생성 해준다.

[root@ruo91 ~]# mkdir /var/lib/awstats

해당 로그에 대한 자료를 웹에서 확인 하려면 프로파일이 업데이트 되어야 하므로 아래와 같이 한다.

[root@ruo91 ~]# /usr/local/awstats/tools/awstats_updateall.pl now
Running
‘”/usr/local/awstats/wwwroot/cgi-bin/awstats.pl” -update
-config=www.yongbok.net -configdir=”/etc/awstats”‘ to update config
www.yongbok.net
Create/Update database for config “/etc/awstats/awstats.www.yongbok.net.conf”
by AWStats version 6.9 (build 1.925)
From data in log file “/home/apache2-log/www/www-access-2009-10-08.log”…
Phase 1 : First bypass old records, searching new record…
Direct access after last parsed record (after line 475)
Jumped lines in file: 475
Found 475 already parsed records.
Parsed lines in file: 1
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 1 new qualified records.

로그가 변경 될때 마다 수동으로 업데이트하기 번거우므로 crontab 으로 5분마다 업데이트 하도록 설정 한다.

[root@ruo91 ~]# echo \
‘*/5    *    *    *    *    root    /usr/local/awstats/tools/awstats_updateall.pl now’ >> /etc/crontab

정상 등록 되었나 확인
[root@ruo91 ~]# cat /etc/crontab | grep awstats
*/5     *       *       *       *       root    /usr/local/awstats/tools/awstats_updateall.pl now

이제 웹 페이지에서 확인 해보면 된다.