질문&답변
클라우드/리눅스에 관한 질문과 답변을 주고 받는 곳입니다.
리눅스 분류

awstats 질문 드립니다.

작성자 정보

  • 임근식 작성
  • 작성일

컨텐츠 정보

본문

 

 

일반적으로 웹로그 분석은 Webalizer를 많이 사용하나, 최근에는 질문자 분이 문의하신  awstats처럼

 보다 괜찮은 인터페이스 및 한글화된 awstats를 설치를 하여 운영하는 분들이 많습니다.


우선, 필자가 테스트한 배포판은  RedHat 7.3 및 9  , Fedora Core 3,4 버전에서도 설치하는데 문제는 없었다.

 


    관련사이트 : http://awstats.sourceforge.net

    데모사이트 : http://awstats.sourceforge.net/cgi-bin/awstats.pl

 

 


1. 다운로드

 


  다음 주소에서 awstats 6.4 버전을 다운받아 설치하려는 서버로 옮겨 놓는다.

 

 

 

2. 압축 풀기, 기본 디렉토리 생성

 


    # tar xvfz awstats-6.4.tgz

    # mv awstats-6.4 /usr/local/awstats

    # chmod 755 /usr/local/awstats/

    # chown -R root.root /usr/local/awstats/

    # mkdir /etc/awstats

    # mkdir /var/lib/awstats

 

 

 

3. 설치 스크립트 실행

 


    # cd /usr/local/awstats/tools

    # ./awstats_configure.pl

 


  설치 중에 3번 정도 물어보는데, 아파치 환경설정파일의 절대경로 위치와, 처음 설치시 설정파일 생성 여부('y'로 답하면 된다), 그리고 임의의 이름을 정하면 된다. 필자는 nfo.pe.kr 사이트에 로그분석기를 설치하므로 세 번째의 이름을 nfo.pe.kr로 적었다.

 

 

 

4. 설정파일의 수정

 


  이제 /etc/awstats/ 디렉토리 밑에 awstats.[자신이 정한 이름].conf 파일이 생성된 것을 볼 수 있다. 필자의 경우 파일명은 다음과 같다.

 


    /etc/awstats/awstats.nfo.conf

 


  이 파일을 열어서 51번째 라인의 LogFile의 지정 값을 로그 분석하고자 하는 파일명으로 수정한다. 일반적으로 아파치 로그파일은 /var/log/httpd/ 디렉토리에 위치할 것이다. 다음은 필자의 경우 수정한 예제이다.

 


    # cat /etc/awstats/awstats.nfo.conf | grep ^LogFile

    LogFile="/var/log/httpd/nfo.pe.kr-access_log"

 

 

 

5. httpd.conf 파일의 수정

 


  필자의 경우 안녕 배포판에 rpm으로 Apache를 설치하였으므로 Apache 환경설정파일의 위치는 /etc/httpd/conf/httpd.conf 파일이다. 

  위에서 /usr/local/awstats/tools 디렉토리에 있는 awstats_configure.pl 파일을 실행하여 제대로 설치하였다면 httpd.conf 파일의 마지막 부분에 다음과 같은 내용이 추가되어 있을 것이다.

 


    #

    # 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/"

    ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"

    

    #

    # This is to permit URL access to scripts/files in AWStats directory.

    #

    

        Options None

        AllowOverride None

        Order allow,deny

        Allow from all

    

 


  혹시 httpd.conf 파일에 위의 내용이 추가되어 있지 않다면 /usr/local/awstats/tools/httpd_conf 파일의 내용을 그대로 복사하여 httpd.conf 파일에 넣어주면 된다.

 


  또한 httpd.conf 파일에서 로그 파일의 포맷을 combined 로 변경해 주어야 한다. 일반적으로 로그파일의 포맷은 common으로 되어 있는 경우가 대부분이다. 필자 역시 다음과 같이 common 포맷으로 되어 있었다.

#####[invain.pe.kr ]#####################################

    ServerAdmin admin@invain.pe.kr
    DocumentRoot /account/invain/public_html
    ServerName invain.pe.kr
    ServerAlias
www.invain.pe.kr invain.pe.kr
    ErrorLog logs/invain.pe.kr-error_log
    CustomLog logs/invain.pe.kr-access_log combined
    #CustomLog logs/invain.pe.kr-access_log common
##################################################################

 

 

    CustomLog /var/log/httpd/nfo.pe.kr-access_log common env=!img-nosave,!CodeRedNimda

 


  이것을 다음과 같이 combined로 수정하여 준다.

 


    CustomLog /var/log/httpd/nfo.pe.kr-access_log combined env=!img-nosave,!CodeRedNimda

 

 

 

6. 기존 로그파일의 내용 삭제, Apache 재시작

 


  기존의 로그파일인 /var/log/httpd/nfo.pe.kr-access_log 파일의 포맷이 common
에서 combined로 변경되었으므로, 로그파일에 쌓인 로그를 모두 지운 후에
Apache를 재실행한다.

 

 

 

7. 로그분석 실행 밑 웹페이지에서 확인

 


  여기까지 마친 후, awstats 로그분석기를 실행하려면 다음과 같이 한다
( -config 옵션의 값은 [자신이 정한 이름]을 적으면 된다).

 


  #> /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=nfo.pe.kr
Update for config "/etc/awstats/awstats.10000ddang.com.conf"
With data in log file "/usr/local/apache/logs/10000ddang.com-access_log"...
Phase 1 : First bypass old records, searching new record...
Direct access after last parsed record (after line 316)
Jumped lines in file: 316
 Found 316 already parsed records.
Parsed lines in file: 60
 Found 0 dropped records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 60 new qualified records.

 

 

  웹브라우저에서 다음 주소로 확인할 수 있다.

 


    http://도메인주소/awstats/awstats.pl?config=[자신이 정한 이름]

 

 

 

 


8. Cron 등록

 


  awstats 로그분석기를 일정 간격으로 자동 실행하기 위하여 /etc/crontab 파일에 다음을 추가한다.

 


    30 1-24/12 * * root /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=nfo.pe.kr

 


   하루 두 번씩 cron 데몬이 정기적으로 업데이트를 하고 있다. 업데이트 주기는,
사이트의 방문자가 많을 수록 짧게 하면 된다.

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,287 명
  • 현재 강좌수 :  36,942 개
  • 현재 접속자 :  404 명