awstats 의 장점
1. 사용자에게는 한글 메뉴를 제공합니다.
2. 작업 스케줄러를 이용하여 일단 설정만 완료되면 매일 자동으로 업데이트가 됩니다.
3. 웹을 통하여 분석 결과를 볼 수 있습니다.
4. conf 파일을 hosting 중인 도메인별로 설정하면 여러 도메인 각각에 대해 분석 할 수 있습니다.
다운로드 http://awstats.sourceforge.net
다운로드 위치는 아무곳이나 상관없습니다.
1> 다운로드
강좌에서는 편하게 /root 디렉토리에 다운 받겠습니다
[root@ns ~]# wget http://prdownloads.sourceforge.net/awstats/awstats-6.5.tar.gz
다운 받은 파일을 tar 명령어를 이용하여 압축 해제 합니다.
[root@ns ~]# tar xvfz awstats-6.5.tar.gz
mv 명령어를 이용하여 awstats-6.5 파일을 /usr/local/awstats로 이동합니다.
[root@ns ~]# mv awstats-6.5 /usr/local/awstats/
chmod 명령어를 이용하여 웹으로 접근가능 하도록 퍼미션을 변경합니다.
[root@ns ~]# chmod -R 755 /usr/local/awstats/
) 환경설정 디렉토리 및 데이터 디렉토리 생성
① 환경설정 파일이 위치할 디렉토리를 생성합니다.
[root@ns ~]# mkdir /etc/awstats
② 데이터파일이 위치할 디렉토리를 생성합니다.
[root@ns ~]# mkdir /var/lib/awstats
2> awstats_configure.pl 컴파일
리눅스 쉘 명령어
awstats_configure.pl 파일이 위치한 /usr/local/awstats/tools 디렉토리로 이동합니다.
[root@localhost ~]# cd /usr/local/awstats/tools/
awstats_configure.pl 파일을 실행합니다.
[root@localhost tools]# ./awstats_configure.pl
awstats 디렉토리지정
디폴트로 /usr/local/awstats로 지정되어 있기 때문에 를 입력합니다.
Do you want to continue setup from this NON standard directory [Yn] ? y
config 파일을 생성 할 것인지 묻는 화면입니다. y를 입력합니다.
ffile (required if first install) [y/N] ? y
해당 도메인을 입력 합니다.
xinet.kr
Your web site, virtual server or profile name:
> xinet.kr
config 파일을 저장할 디렉토리를 지정 합니다. 기본 /etc/awstats로 지정되어있기 때문에 Enter를 입력합니다.
Directory path to store config file(s) (Enter for default):
3> 설정파일 변경
파일에 설정된 환경을 확인합니다.
[root@localhost tools]# vi /etc/awstats/awstats.xinet.kr.conf
LogFile 경로지정
apache서버의 access_log파일의 경로를 지정해줍니다. 51번 라인
LogFile=”/usr/local/apache/logs/access_log”
LogFormat 확인 122번 라인
LogFormat=1
SiteDomain 확인 153번라인
SiteDomain="xinet.kr"
HostAliases 확인 168번 라인
HostAliases="xinet.kr www.xinet.kr 127.0.0.1 localhost"
DirData 확인 203번 라인
DirData=”/var/lib/awstats”
Lang 확인 웹페이지 화면의 언어를 한국어로 설정합니다. 891번 라인
Lang=”ko”
여기까지 확인하면 wq를 입력후 저장 합니다.
4> 아파치 httpd.conf 설정 확인
로그파일의 형식을 지정합니다. (기존 형식은 CustomLog logs/access_log common ) 아래와 같이 변경
CustomLog /usr/local/apache/logs/access_log combined
CGI 실행권한 부여 및 스크립트Alias 설정 확인
이 설정은 . awstats_configure.pl 컴파일에 의해 자동 설정된 부분입니다.
스크립트Alias 설정부분
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
스크립트Alias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to 스크립트s/files in AWStats directory.
#
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directoty>
#ry>
AddHandler 확인
CGI를 인식할 수 있는 pl 확장자를 확인합니다. pl 확장가가 없을경우 추가 입력 합니다.
AddHandler cgi-스크립트 .cgi .pl
VirtualHost 설정
가상호스트를 추가 합니다. DocumentRoot 는 awstats의 하위 디렉토리인
wwwroot 로 설정합니다.
<VirtualHost xxx.xxx.xxx.xxx>
DocumentRoot /usr/local/awstats/wwwroot
ServerName xinet.kr
</VirtualHost>
5> 통계분석을 위한 업데이트
첫 통계의 분석/갱신은 다음의 명령어를 사용한 한번의 수동적인 방법으로 이루어 집니다.
첫단계의 통계분석을 위해 /usr/local/awstats/wwwroot/cgi-bin로 이동합니다.
[root@ns ~] cd /usr/local/awstats/wwwroot/cgi-bin
통계분석을 업데이트 합니다.
[root@ns ~] perl awstats.pl -update -config=xinet.kr
Update for config "/etc/awstats/awstats.xinet.kr.conf"
With data in log file "/usr/local/apache/logs/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: 1639
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 1639 new qualified records.
6> crontab 등록
쉘을 이용하여 작성하는것이 더 좋습니다.
[root@ns shell]# vi /shell/awstats
내용 입력
#!/bin/bash
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=xinet.kr
저장합니다.
root권한으로 사용할 수 있게 퍼미션을 변경합니다.
[root@ns shell]# chmod 700 /shell/awstats
통계분석을 5분주기로 실행하기 위해 crontab에 등록 합니다.
[root@ns shell]# crontab -e
내용 입력
*/5 * * * * /shell/awstats
crontab을 재시작하겠습니다.
[root@ns shell]# /etc/rc.d/init.d/crond restart
7> 웹페이지에서 확인
웹페이지에서 확인 하는 방법은 아래와 같습니다.
http://도메인/awstats/awstats.pl?config=도메인
위에서 설정한 xinet.kr 도메인을 입력합니다.
http://xinet.kr/awstats/awstats.pl?config=xinet.kr
초기 화면은 전체 요약을 나타냅니다.