메뉴 닫기

웹로그 분석 프로그램 설치

안녕하세요 기술지원팀 조기량입니다.

웹로그 분석 프로그램(awstats)에 대해 포스팅 하도록 하겠습니다.

1-1 awstats ?

awstatsweb, ftp, mail 서버의 통계를 그래픽 적으로 생성해 주는 기능성 툴 입니다.

awstats 로그 분석은 CGI 나 다른 명령어로 부터 그리고 로그에 포함된 모든 정보를 보여줄 수 있고, 그 안에 그래픽적으로 웹페이지가 포함되어 있습니다.

1-2 awstats의 특징

웹로그가 보이는 모든 정보를 알기쉽게 보여줍니다.

무제한의 로그파일 사이즈

모양과 컬러는 각자의 사이트에 필적합니다.

사용이 쉽습니다.

awstats의 가장 큰 장점은 설치가 간단하고 추가적인 작업이 거의 없다는 점 입니다.

2-1 awstats 설치

apache 2.2에서 설치 진행하였습니다.

http://awstats.sourceforge.net에서 설치 버전을 다운받을 수 있습니다.

[root@rlfiddlaks-1350 src]# wget https://sourceforge.net/projects/awstats/files/AWStats/6.5/awstats-6.5.tar.gz/download

[root@rlfiddlaks-1350 src]# ll

합계 1952

drwxr-xr-x. 5 root root 4096 2017-09-09 09:33 ./

drwxr-xr-x. 17 root root 4096 2017-03-12 01:07 ../

drwxr-xr-x 8 root root 4096 2017-03-12 01:21 APM_Setup/

-rw-r–r– 1 root root 1051780 2005-12-25 06:41 download

drwxrwxr-x 11 root root 4096 2017-08-29 14:27 fail2ban-0.8.14/

-rw-r–r– 1 91jos users 228121 2017-08-29 14:27 fail2ban-0.8.14.tar.gz

위와 같이 파일 이름이 download로 되어 있어 파일명을 변경해 줍니다.

[root@rlfiddlaks-1350 src]# mv download awstats-7.6.tar.gz

[root@rlfiddlaks-1350 src]# ll

합계 1952

drwxr-xr-x. 5 root root 4096 2017-09-09 09:34 ./

drwxr-xr-x. 17 root root 4096 2017-03-12 01:07 ../

drwxr-xr-x 8 root root 4096 2017-03-12 01:21 APM_Setup/

-rw-r–r– 1 root root 1051780 2005-12-25 06:41 awstats-7.6.tar.gz

drwxrwxr-x 11 root root 4096 2017-08-29 14:27 fail2ban-0.8.14/

-rw-r–r– 1 91jos users 228121 2017-08-29 14:27 fail2ban-0.8.14.tar.gz

압축을 풀고 설치를 진행 합니다.

[root@rlfiddlaks-1350 src]# tar zxvf awstats-7.6.tar.gz

[root@rlfiddlaks-1350 src]# mv awstats-7.6 /usr/local/awstats

[root@rlfiddlaks-1350 src]# chown -R root:root awstats

[root@rlfiddlaks-1350 src]# chmod 755 awstats

[root@rlfiddlaks-1350 src]# cd awstats/tools/

[root@rlfiddlaks-1350 tools]# perl awstats_configure.pl

Do you want to continue setup from this NON standard directory [yN] ? Y

NON 표준 디렉토리 설치를 계속 하겠습니까? Y

file (required if first install) [y/N] ? Y

처음 설치하는 건가요? Y

Your web site, virtual server or profile name:

> 91

설정파일 이름 지정

Directory path to store config file(s) (Enter for default):

>

/etc/awstats 로 설정할꺼면 enter

그리고 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.

#

<Directory “/usr/local/awstats/wwwroot”>

Options None

AllowOverride None

Order allow,deny

Allow from all

</Directory>

2-2 awstats 설정

vi /etc/awstats/awstats.91 를 열어 설정을 해줍니다.

LogFile=”/usr/local/apache/logs/91jos.xyz” => 51번째 줄 사용하는 로그위치를 지정합니다.

DirData=”/usr/local/awstats” => 204번째 줄 awstats를 설치한 위치를 지정합니다.

Lang=”ko” => 894번째 줄 한국어로 언어 설정을 합니다.

이후 httpd.conf, httpd-vhosts.conf 파일의 로그파일 형식을 combined로 지정합니다.

Common 형식보다 더 자세히 로그를 출력을 해주고 awstats 자체가 combined 기반으로 분석을 하기때문입니다.

이제 아파치 재시작 후

/usr/local/awstats/wwwroot/cgi-bin/awstats.il -update -config=91

를 실행합니다.

위 명령어를 입력하였을때 아래와 같은 에러가 발생하면

vi /etc/awstats/awstats.91.conf를 열어서 LogFormat=”%host %other %logname %time1 %methodurl %code %hytesd” 를 적고 저장하고

/usr/local/awstats/tools/awstats_updateall.pl now 명령어로 업데이트 시켜 줍니다.

[root@rlfiddlaks-1350 tools]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=91

Create/Update database for config “/etc/awstats/awstats.91.conf” by AWStats version 7.6 (build 20161204)

From data in log file “/usr/local/apache/logs/91jos.xyz”…

Phase 1 : First bypass old records, searching new record…

Searching new records from beginning of log file…

AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log.

Your log file /usr/local/apache/logs/91jos.xyz must have a bad format or LogFormat parameter setup does not match this format.

Your AWStats LogFormat parameter is:

1

This means each line in your web server log file need to have “combined log format” like this:

111.22.33.44 – – [10/Jan/2001:02:14:14 +0200] “GET / HTTP/1.1” 200 1234 “http://www.fromserver.com/from.htm” “Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)”

And this is an example of records AWStats found in your log file (the record number 50 in your log):

115.68.87.2 – – [12/Mar/2017:02:03:46 +0900] “GET / HTTP/1.1” 200 2342

Setup (‘/etc/awstats/awstats.91jos.xyz.conf’ file, web server or permissions) may be wrong.

Check config file, permissions and AWStats documentation (in ‘docs’ directory).

그러면 아래와 같이 정상적으로 실행이 되는 것을 확인할 수 있습니다.

Running ‘”/usr/local/awstats/wwwroot/cgi-bin/awstats.pl” -update -config=91 -configdir=”/etc/awstats”‘ to update config 91

Create/Update database for config “/etc/awstats/awstats.91.conf” by AWStats version 6.6 (build 1.887)

From data in log file “/usr/local/apache/logs/access_log”…

Phase 1 : First bypass old records, searching new record…

Direct access to last remembered record has fallen on another record.

So 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: 247

Found 0 dropped records,

Found 1 corrupted records,

Found 0 old records,

Found 246 new qualified records.

이제 웹에서 설치된 awstats를 확인해 보겠습니다.

http://91jos.xyz/awstats/awstats.pl?config=91

로 들어가면 아래와 같이 설치된 awstats를 확인할 수 있습니다.

 

2-3 awstats 페이지 설명

초기 접속 화면 입니다.

글씨가 작아서 잘 보이지는 않지만 왼쪽에 여러가지 메뉴들이 있습니다.

전체 요약

올해의 접속통계

이번달 접속통계

요일별 통계

시간별 통계

국가

호스트 등

올해의 접속 통계입니다.

이번달 접속통계 입니다.

요일/시간별 통계 입니다.

호스트 부분 입니다.

=> 방문자 도메인과 접속한ip, 마지막 접속 시간등을 확인할 수 있습니다.

3-1 GeoIP 와 연동

awstats GeoIP를 연동하여 방문자 통계를 국가별로 확인 할 수 있습니다.

우선 GeoIP 데이터 베이스를 다운받고 디렉토리를 만들어 이동 시켜 줍니다.

[root@rlfiddlaks-1350 src]#

wgethttp://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

[root@rlfiddlaks-1350 src]# gzip -d GeoIP.dat.gz

[root@rlfiddlaks-1350 src]# mkdir /usr/local/share/GeoIP

[root@rlfiddlaks-1350 src]# mv GeoIP.dat /usr/local/share/GeoIP/

이후 PurePerl 모듈 설치를 해줍니다.

[root@rlfiddlaks-1350 src]# wget http://geolite.maxmind.com/download/geoip/api/pureperl/Geo-IP-PurePerl-1.24.tar.gz

[root@rlfiddlaks-1350 src]# tar zxvf Geo-IP-PurePerl-1.24.tar.gz

[root@rlfiddlaks-1350 src]# cd Geo-IP-PurePerl-1.24

[root@rlfiddlaks-1350 src]# perl Makefile.PL

[root@rlfiddlaks-1350 src]# make && make install

마지막으로 awstats와 연동을 하여 줍니다.

vi /etc/awstats/awstats.91.conf 를 열어

아래 내용을 추가해 줍니다.

LoadPlugin=”geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat”

이후 awstats 설정을 업데이트 하여 줍니다.

[root@rlfiddlaks-1350 src]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=91

그리고 페이지를 열어서 확인을 하면 아래와 같이 국가가 표시되어 나타나는 것을 확인 할 수 있습니다.

awstats 페이지의 왼쪽 메뉴중에 알수없는 ip 주소를 클릭하면 아래와 같이 확인되지 않은 ip가 접속을 시도한 것을 볼 수 있습니다.

 

이상으로 포스팅을 마치도록 하겠습니다.

감사합니다.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x