1. 최신버전 다운
http://awstats.sourceforge.net에서 최신버전을 다운로드 받을 수 있다.
Awstats는 보안이슈가 많으므로 반드시 최신버전을 다운로드 받을 수 있도록 한다.
2. 압축풀기
[root@localhost src]# tar zxvf awstats-6.6.tar.gz
3. 이동
[root@localhost src]# mv awstats-6.6 /usr/local/awstats
4. 권한설정
[root@localhost src]# chmod -R 705 /usr/local/awstats
5. awstats 설정파일 생성하기
[root@localhost tools]# cd /usr/local/awstats/tools
[root@localhost tools]# perl awstats_configure.pl
----- AWStats awstats_configure 1.0 (build 1.6) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).
-----> Running OS detected: Linux, BSD or Unix
-----> Check for web server install
Found Web server Apache config file '/usr/local/apache/conf/httpd.conf'
-----> Check and complete web server config file '/usr/local/apache/conf/httpd.conf'
Warning: You Apache config file contains directives to write 'common' log files
This means that some features can't work (os, browsers and keywords detection).
Do you want me to setup Apache to write 'combined' log files [y/N] ? y <-- apache 로그형식을 combined로 했는지를 확인하고 있다. 아직combined로 안했더라도 나중에 설정하면 되므로 “y”
Add 'Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'
Add 'Alias /awstatscss "/usr/local/awstats/wwwroot/css/"'
Add 'Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'
Add 'ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'
Add '' directive
AWStats directives added to Apache config file.
-----> Update model config file '/usr/local/awstats/wwwroot/cgi- bin/awstats.model.conf'
File awstats.model.conf updated.
-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y <-- 시스템에 awstats 를 처음 설정 하는 것인지 확인하고 있다. 처음이면 “y”를 아니면 “n”
----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.domain.com <-- 설정 파일 이름을 정한다.
-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
> (엔터) <-- 설정 디렉토리를 정한다. 보통 디폴트(/etc/awstats)로 설정한다.
-----> Create config file '/etc/awstats/awstats.www.domain.com.conf'
Config file /etc/awstats/awstats.www.domain.com.conf created.
-----> Restart Web server with '/sbin/service httpd restart'
-----> 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:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.domain.com
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...
A SIMPLE config file has been created: /etc/awstats/awstats.www.domain.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.domain.com' with command:
> perl awstats.pl -update -config=www.domain.com
You can also read your statistics for 'www.domain.com' with URL:
> http://localhost/awstats/awstats.pl?config=www.domain.com
Press ENTER to finish...
httpd.conf 끝부분에 다음과 같은 내용이 추가 되었는지를 확인한다. 만약 추 가되지 않았다면 수동으로 만들어 준다.
[root@localhost tools]# vi /usr/local/apache/conf/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
awstats의 설정파일을 적절히 수정해 주어야 한다.
위에서 설정파일을 www.domain.com로 만들어 주었으므로 /etc/awstats/awstats.www.domain.com.conf 파일을 찾아 수정해 주면 된다.
51 Line <-- www.domain.com 로그파일 위치
51 #LogFile="/var/log/httpd/mylog.log"
52 LogFile="/usr/local/apache/logs/domain_access_log" <-- 실제 사용되는 아파치 로그 파일
204 Line <-- awstats의 설치 위치
204 #DirData="/var/lib/awstats"
205 DirData="/usr/local/awstats"
894 Line <-- 언어선택
894 #Lang="auto"
895 Lang="ko"
로그파일 형식 combined 지정
★ 아직까지 apache access로그 형식을 combined 로 지정하지 않았다면 combined로 지정한다. 기존의 로그는 삭제한다.
1) httpd.conf 파일 내용중
# CustomLog logs/access_log common
CustomLog logs/access_log combined
2) vitual host 부분중
# CustomLog /usr/local/apache/logs/domain_access_log common
CustomLog /usr/local/apache/logs/domain_access_log combined
6. 로그 분석파일 만들기
[root@localhost tools]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.domain.com
Create/Update database for config "/etc/awstats/awstats.www.domain.com.conf" by AWStats version 6.6 (build 1.876)
From data in log file "/home/domain/public_html/logs/www.domain.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: 33732
Found 2 dropped records,
Found 855 corrupted records,
Found 0 old records,
Found 32875 new qualified records.
7. 웹상에서 awstats 확인하기
http://domain.com/awstats/awstats.pl?config=www.domain.com
8. 클론으로 로그 분석 파일 갱신하기
매시간 10분마다 로그 분석 파일을 갱신(시간은 적절히 설정)
# crontab -e
10 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.domain.com
이와 같은 방법으로 시스템내의 여러 웹사이트를 로그 분석 파일을 여러개 설정할 수 있다.
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
9. awstats 디렉토리 아파치 인증 설정하기
awstats는 보안 이슈가 발생할 가능성이 많으므로 아피치 인증을 설정한다.
[root@domain wwwroot]# vi /usr/local/apache/conf/httpd.conf
Options None
AllowOverride All <-- 수정
Order allow,deny
Allow from all
[root@domain wwwroot]# vi .htaccess
AuthName "아이디와 암호를 입력하세요."
AuthType Basic
#AuthUserFile /usr/local/apache/conf/.htpasswd
AuthUsrFile /usr/local/awstats/wwwroot/.htpasswd
AuthGroupFile /dev/null
require valid-user
[root@domain wwwroot]# htpasswd -c .htpasswd admin
New password:
Re-type new password:
Updating password for user admin
웹상에서 apache 인증이 되는지 확인한다.