install awstats

awstats툴은 web log analytics tools이다.  간단한 설치와 설정이 맘에 든다.

case centos or not package – awstats 7.0

1. 설치
awstats 최신소스 : http://sourceforge.net/projects/awstats

wget http://awstats.sourceforge.net/files/awstats-7.0.tar.gz
tar xvfz awstats-7.0.tar.gz
mv awtats-7.0 /usr/local/awstats
chmod -R 755 /usr/local/awstats/wwwroot /usr/local/awstats/tools/*.pl
mkdir /etc/awstats /var/lib/awstats

2. 셋팅
awstats 분석 기능을 도메인별로 추가 하기 위해선 ubuntu와 다르게 다음의 스크립트를 실행한다. 문답식이다.
/etc/awstats 에 추가로 문답에 입력했던 프로필명으로 기본 설정 파일이 생기며, 요 파일을 알맞게 수정해준다. LogFile을 해당하는 도메인에 맞게 수정 Logformat 은 보통 1을 사용하며, apache에서는 combined를 사용한다.

ubuntu의 경우 log를 logrotate가 gz로 압축해버리는데(centos는 그대로) 과거의 로그 파일 처리를 위해선 압축을 풀고, /usr/local/awstats/tools/logresolvemerge.pl 로 하나의 log파일로 머지한 다음에 분석하면 된다.

cd /var/log/apache2
gzip -d xxx.test.com-access.log.*.gz
/usr/local/awstats/tools/logresolvemerge.pl xxx.test.com-access.log.* >> xxx.test.com-access-combined.log
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=xxx.test.com -LogFile="/var/log/apache2/xxx.test.com-access-combined.log"
cd /usr/local/awstats/tools/
./awstats_configure.pl
vi /etc/awstats/awstats-xxx-test-com-conf

ubunt처럼 cron.hourly에 등록하자.

vi /etc/cron.hourly/awstat-xxx.test.com.sh

#!/bin/sh
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=xxx.test.com

덧. 최신 버젼들에는 브라우저 정보등 각종 데이타가 최신임으로 굳히 ubuntu처럼 패키지로 깔 필요가 없을듯 하다.

case : ubuntu (계정 root 기본) – awstats 6.9

참조 :
http://ubuntu-tutorials.com/2008/01/16/configuring-awstats-on-ubuntu-server/

1. 설치

aptitude install awstats

2. 기본 셋팅
각 virtual host 별로 생성이 가능하니 /etc/awstats/awstats.conf 를 도메인별로 복사해서 사용한다.

cp /etc/awstats/awstats.conf /etc/awstats/awstats.xxx.test.com.conf
vi /etc/awstats/awstats.xxx.test.com.conf

LogFile="/var/log/apache2/xxx.text.com-access.log"
LogFormat=1
SiteDomain="xxx.test.com"
HostAliases="xxx.test.com localhost 127.0.0.1

여기서 좀더 확인해야 할것은 DirData 지시어에 로그 분석 파일이 위치한다는 것이다. plugin등이 잘못되었다고 생각되면 해당 폴더를 지워주면 된다.

그리고 아파치 셋팅을 추가해준다.

Alias /awstatsclasses "/usr/share/awstats/lib/"
Alias /awstats-icon/ "/usr/share/awstats/icon/"
Alias /awstatscss "/usr/share/doc/awstats/examples/css"
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /awstats/ /usr/lib/cgi-bin/
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch

ubuntu의 경우 log를 logrotate가 gz로 압축해버리는데 과거의 로그 파일 처리를 위해선 압축을 풀고, /usr/share/doc/awstats/examples/logresolvemerge.pl 로 하나의 log파일로 머지한 다음에 분석하면 된다.

cd /var/log/apache2
gzip -d access.log.*.gz
/usr/share/doc/awstats/examples/logresolvemerge.pl access.log.* >> access_combined.log
/usr/lib/cgi-bin/awstats.pl -config=xxx.test.com -LogFile="/var/log/apache2/access_combined.log"

최근 로그는 다음 명령어를 통해서 업데이트 가능하다. cron.hourly에 등록하자.

touch /etc/cron.hourly/awstat-xxx.test.com.sh;chmod 700 /etc/cron.hourly/awstat-xxx.test.com.sh
vi /etc/cron.hourly/awstat-xxx.test.com.sh

#!/bin/sh
/usr/lib/cgi-bin/awstats.pl -config=xxx.test.com -update

추가로 geoip 기능을 사용해 보자.
geoip plugin 기능을 쓰기 위해선 다음과 같이 한다.  참조 : http://blog.sunghwanyoo.com/tc/59

case ubuntu :

apt-get install libgeoip1 libgeoip-dev libgeo-ip-perl #use geoip

case centos :

yum install GeoIp GeoIP-devel
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
cd GeoIP-1.4.6;./configure --prefix=/usr;make;make install;
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gzip  -d GeoIP.dat.gz
mv GeopIP.dat /var/lib/GeoIP/
wget http://geolite.maxmind.com/download/geoip/api/perl/Geo-IP-1.38.tar.gz
cd Geo-IP-1.38;perl Makefile.PL;make;make test;make install;

geocity plugin 기능도 추가하자

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gzip -d GeoLiteCity.dat.gz
mv GeoLiteCity.dat /usr/share/GeoIP #ubuntu :/var/lib/GeoIP/, centos : /var/lib/GeoIP/

그리고 GeoIP를 활성화를 위해선 geoip 부분을 활성화 시키고, GeoCity를 활성화기 위해선 geoip_city_maxmind 부분을 활성화 시킨다

DNSLookup=0 or 2
LoadPlugin="geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat"
#LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/share/GeoIP/GeoLiteCity.dat" # case : centos 에서 오류 나온다

글쓴이

yupmin

Inside Deep Throat.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.