###########참조 사이트###############
참조 : http://awstats.sourceforge.net
###########참조 사이트###############

 

###########초기 확인#################
awstats가 정상적으로 동작하기 위해서는 perl이 꼭 필요하며,
apache에 perl module을 올리던지 아니면 아래에 경로의 pl 소스에서 perl이 설치된 경로를 확인

a) /usr/local/awstats/wwwroot/cgi-bin
b) /usr/local/awstats/wwwroot/cgi-bin/lib
c) /usr/local/awstats/wwwroot/cgi-bin/plugins

=== perl 설치 확인 ===
[root ~] rpm -q perl
perl-5.8.8-32.el5_6.3
[root ~]

혹은

[root ~]# find / -name perl
/usr/bin/perl
[root ~]#
###########초기 확인#################

 

###########설치 준비#################
[root ~]# tar xvfz awstats-6.5.tar.gz
[root ~]# mv awstats-6.5 /usr/local/awstats
[root ~]# mkdir /etc/awstats
[root ~]# mkdir /var/lib/awstats

 

###########설치 하기#################
[root ~]# cd /usr/local/awstats/tools/
[root ~]# 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
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 '<Directory>' 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   <== y 입력

-----> 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:
> ifull.co.kr          <==자신의 도메인주소 작성

-----> 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):
>             <== 기본 설치 일때 엔터

-----> Create config file '/etc/awstats/awstats.ifull.co.kr.conf'
Config file /etc/awstats/awstats.ifull.co.kr.conf created.

-----> Restart Web server with '/sbin/service httpd restart'
httpd: unrecognized service

-----> 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=ifull.co.kr
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.ifull.co.kr.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'ifull.co.kr' with command:
> perl awstats.pl -update -config=ifull.co.kr
You can also read your statistics for 'ifull.co.kr' with URL:
> http://localhost/awstats/awstats.pl?config=ifull.co.kr

Press ENTER to finish...

###########설치 완료#################


###########환경 설정#################
[root ~]# cd /etc/awstats
[root ~]# ls
-rw-r--r--  1 root root 61120  2월 23 11:13 awstats.ifull.co.kr.conf  <== 이 파일이 없으면 다시 설치
[root ~]# vi awstats.ifull.co.kr.conf
.... 51라인의
LogFile="/var/log/httpd/mylog.log"을
LogFile="/backup1/apache/logs/ifull_access_log"   <== 자신의 아파치 로그 파일의 위치를 적는다.

   *** 아파치 로그 위치를 모를 경우 ***
   [root ~]# vi /usr/local/apache/conf/extra/httpd-vhosts.conf
   파일 안에
   <VirtualHost *:80>
     ServerAdmin master@ifull.co.kr
     DocumentRoot /home/ifull/public_html/
     ServerName  ifull.co.kr
     ServerAlias www.ifull.kr
     CustomLog /backup1/apache/logs/ifull_access_log combined
     TransferLog /backup1/apache/logs/ifull_acc2ss_log
     ErrorLog /backup1/apache/logs/ifull_error_log
   </VirtualHost>
   이렇게 되어 있으면
   로그 경로는
   /backup1/apache/logs/ifull_access_log 이것이 로그파일 위치임

.... 906라인의
Lang="auto" 를
Lang="ko"   <== awstats 실행시 한글 출력하기
로 변경후 저장 끝내기

###########환경 설정 끝###############

 

###########처음 실행###############
[root ~]# cd /usr/local/awstats/wwwroot/cgi-bin
[root ~]# perl awstats.pl -update -config=ifull.co.kr  <== 자신의 도메인 주소를 작성
.
.
.
.
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/2012: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):
***.***.***.*** - - [10/Jan/2012:02:14:10 +0900] "GET /xe/images/factory/*********.gif HTTP/1.1" 200 19940
Setup ('/etc/awstats/awstats.ifull.co.kr.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).

  위와 같이 오류 메시지가 나올경우 아파치 VirtualHost의 로그생성을 바꿔줘야 한다.
   <VirtualHost *:80>
     ServerAdmin master@ifull.co.kr
     DocumentRoot /home/ifull/public_html/
     ServerName  ifull.co.kr
     ServerAlias www.ifull.co.kr

   #  CustomLog /backup1/apache/logs/ifull_access_log combined
     SetEnvIfNoCase Request_URL (gif|png|jpg|css|js|bmp|jpeg|swf)$ IMAGE=1
        CustomLog /backup1/apache/logs/ifull_access_log combined env=!img-nosave,!CodeRedNimda

     TransferLog /backup1/apache/logs/ifull_acc2ss_log
     ErrorLog /backup1/apache/logs/ifull_error_log
   </VirtualHost>

  위와 같이 /usr/local/apache/conf/extra/httpd-vhosts.conf 을 변경 후 저장한다.
  아파치 제시작 후
  [root ~]# /usr/local/apache/bin/apachectl restart
  [root ~]# perl awstats.pl -update -config=ifull.co.kr
  실행 후 동일한 에러가 나올경우
  기존의 로그 파일을 백업하고 새로 만들고, 아파치 제시작 후 다시 실행해보면 됨.


[root ~]# perl awstats.pl -update -config=ifull.co.kr  <== 자신의 도메인 주소를 작성
Running '"/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=ifull.co.kr -configdir="/etc/awstats"' to update config ifull.co.kr
Update for config "/etc/awstats/awstats.ifull.co.kr.conf"
With data in log file "/usr/local/apache/logs/new-access_log.20120110"...
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: 300
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 300 new qualified records.

[root ~]#

위와 같이 나오면 정상적으로 실행된것임.

[root ~]# cd /var/lib/awstats/
[root ~]# ll
합계 8
-rw-r--r-- 1 root root 6287  1월 10 15:49 awstats012012.ifull.co.kr.txt
[root ~]#

위와 같이 파일이 생성되면 끝난것임.

###########처음 실행 끝############


아파치 로그를 awstats로 변경을 해야만 awstats를 볼수 있으며, 볼때마다 위의 작업을 하기보다는 클론에 등록하면
자동으로 파일이 생성된다.

###########클론 등록###############
[root ~]# crontab -e
00 4 * * * root  /usr/local/awstats/tools/awstats_updateall.pl now  <== 추가하기
[root ~]#
###########클론 등록 끝############


###########웹에서확인##############
http://ifull.co.kr/awstats/awstats.pl?config=ifull.co.kr   <== 자신의 도메인 주소

웹에서 잘 실행되면 하루에 한번씩 업데이트 된 통계를 확인 할수 있다.

############## 끝 ################