awstats
웹 로그 분석기 설치
다운로드 사이트 : http://www.awstats.org/
1. 다운로드 / 압축풀기
# wget http://prdownloads.sourceforge.net/awstats/awstats-6.95.tar.gz
# tar zxvf awstats-6.95.tar.gz
# tar zxvf awstats-6.95.tar.gz
2. 디렉토리 이동 (구동될 디렉토리)
# mv awstats-6.95 awstats
# mv awstats /home/www/
# mv awstats /home/www/
3. 디렉토리 생성
# mkdir /etc/awstats
# mkdir /var/lib/awstats
# mkdir /var/lib/awstats
- 환경설정 파일, 데이터 파일이 저장될 디렉토리
4. 설치전 설정
* 로그 형식 지정 (common or combined)
# vi /usr/local/httpd-2.2.4/conf/httpd.conf
CustomLog logs/access_log combined
CustomLog logs/access_log combined
* 가상 호스트를 사용한다면 가상호스트에도 설정 확인
# vi /usr/local/httpd-2.2.4/conf/extra/httpd-vhost.conf
CustomLog logs/access_log combined
CustomLog logs/access_log combined
* 기존 로그 초기화
# cd /usr/local/httpd-2.2.4/logs/
# > oops4u.com-access_log
# > oops4u.com-access_log
5. 설치 / 설정
# cd /home/www/awstats/tools/
# ./awstats_configure.pl
Do you want to continue setup from this NON standard directory [yN] ? y
Config file path ('none' to skip web server setup):
> /usr/local/httpd-2.2.4/conf/httpd.conf # 아파치 설정파일 경로 (설정 추가함)
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y # 설정파일 생성
Your web site, virtual server or profile name:
> oops4u.com # 설정파일 이름
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
> [enter]
-----> Create config file '/etc/awstats/awstats.oops4u.com.conf'
Config file /etc/awstats/awstats.oops4u.com.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:
/home/www/awstats/wwwroot/cgi-bin/awstats.pl -update -config=oops4u.com
Or if you have several config files and prefer having only one command:
/home/www/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...
A SIMPLE config file has been created: /etc/awstats/awstats.oops4u.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'oops4u.com' with command:
> perl awstats.pl -update -config=oops4u.com
You can also read your statistics for 'oops4u.com' with URL:
> http://localhost/awstats/awstats.pl?config=oops4u.com
# ./awstats_configure.pl
Do you want to continue setup from this NON standard directory [yN] ? y
Config file path ('none' to skip web server setup):
> /usr/local/httpd-2.2.4/conf/httpd.conf # 아파치 설정파일 경로 (설정 추가함)
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y # 설정파일 생성
Your web site, virtual server or profile name:
> oops4u.com # 설정파일 이름
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
> [enter]
-----> Create config file '/etc/awstats/awstats.oops4u.com.conf'
Config file /etc/awstats/awstats.oops4u.com.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:
/home/www/awstats/wwwroot/cgi-bin/awstats.pl -update -config=oops4u.com
Or if you have several config files and prefer having only one command:
/home/www/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...
A SIMPLE config file has been created: /etc/awstats/awstats.oops4u.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'oops4u.com' with command:
> perl awstats.pl -update -config=oops4u.com
You can also read your statistics for 'oops4u.com' with URL:
> http://localhost/awstats/awstats.pl?config=oops4u.com
6. 설정 파일 변경
# vi /etc/awstats/awstats.oops4u.com.conf
LogFile="/usr/local/httpd-2.2.4/logs/oops4u.com-access_log"
Lang="ko"
LogFile="/usr/local/httpd-2.2.4/logs/oops4u.com-access_log"
Lang="ko"
7. 데이터베이스 생성 / 업데이트
# /home/www/awstats/wwwroot/cgi-bin/awstats.pl -update -config=oops4u.com
Create/Update database for config "/etc/awstats/awstats.oops4u.com.conf" by AWStats version 6.95 (build 1.943)
From data in log file "/usr/local/httpd-2.2.4/logs/oops4u.com-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: 2758
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 2758 new qualified records.
Create/Update database for config "/etc/awstats/awstats.oops4u.com.conf" by AWStats version 6.95 (build 1.943)
From data in log file "/usr/local/httpd-2.2.4/logs/oops4u.com-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: 2758
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 2758 new qualified records.
8. crontab 추가
# vi /etc/crontab
# awstats per 5 minutes
*/5 * * * * root perl /home/www/awstats/tools/awstats_updateall.pl now > /dev/null 2>&1
# awstats per 5 minutes
*/5 * * * * root perl /home/www/awstats/tools/awstats_updateall.pl now > /dev/null 2>&1
Troubleshooting
Error: Can't find AWStats program ('awstats.pl').
Use -awstatsprog option to solve this.
Use -awstatsprog option to solve this.
awstats_updateal.pl 실행시 나타나는 위의 오류는 awstats.pl 파일을 찾을 수 없다는 것이다.
파일에 경로를 지정해주면 된다.
# vi /home/www/awstats/tools/awstats_updateall.pl
# Run update process for each config file found
if (-s "$Awstats") { $AwstatsFound=1; }
elsif (-s "/home/www/awstats/wwwroot/cgi-bin/awstats.pl") {
$Awstats="/home/www/awstats/wwwroot/cgi-bin/awstats.pl";
$AwstatsFound=1;
}
# Run update process for each config file found
if (-s "$Awstats") { $AwstatsFound=1; }
elsif (-s "/home/www/awstats/wwwroot/cgi-bin/awstats.pl") {
$Awstats="/home/www/awstats/wwwroot/cgi-bin/awstats.pl";
$AwstatsFound=1;
}
GeoIP
국가별 IP 체크
다운로드 사이트 : http://www.maxmind.com
1. 데이터베이스 다운로드 / 설치
# wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
# gzip -d GeoIP.dat.gz
# mkdir /usr/local/share/GeoIP
# mv GeoIP.dat /usr/local/share/GeoIP/
# gzip -d GeoIP.dat.gz
# mkdir /usr/local/share/GeoIP
# mv GeoIP.dat /usr/local/share/GeoIP/
2. API 다운로드 / 설치
라이브러리를 필요로 하지 않는 PurePerl 모듈 설치
# wget http://geolite.maxmind.com/download/geoip/api/pureperl/Geo-IP-PurePerl-1.24.tar.gz
# tar zxvf Geo-IP-PurePerl-1.24.tar.gz
# cd Geo-IP-PurePerl-1.24
# perl Makefile.PL
# make
# make install
# tar zxvf Geo-IP-PurePerl-1.24.tar.gz
# cd Geo-IP-PurePerl-1.24
# perl Makefile.PL
# make
# make install
3. Awstats 연동
# vi /etc/awstats/awstats.oops4u.com.conf
LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"
LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"
4. 작동 확인
http://mydomain/awstats/awstats.pl?config=mynames
WRITTEN BY
- 손가락귀신
정신 못차리면, 벌 받는다.
,