awstats 설치

리눅스 2015. 6. 24. 20:57


버전 

centos 6.6

awstats 6.5


cd /usr/local/

wget http://firewolf.co.kr/download/linux/PUB/awstats-6.5.tar.gz

tar xvfpz awstats-6.5.tar.gz

mv awstats-6.5 awstats

chown -R root:root awstats

chmod 755 awstats

mkdir /etc/awstats

mkdir /var/lib/awstats


cd /usr/local/awstats/tools

perl ./awstats_configure.pl

y

firewolf.co.kr  (자신이 사용할 도메인을 넣는다.)

/etc/awstats

엔터

엔터


cd /etc/awstats/

vi ./awstats.firewolf.co.kr.conf

LogFile="/var/log/httpd/mylog.log" ==> LogFile="/usr/local/apache/logs/access_log"



cat /usr/local/awstats/tools/httpd_conf  요항목들을

vi /usr/local/apache/conf/httpd.conf 삽입 (설치하면 기본적으로 삽입되어있습니다.)

# Directives to add to your Apache conf file to allow use of AWStats as a CGI.

# Note that path "/usr/local/awstats/" must reflect your AWStats install path.

#

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





vi /usr/local/apache/conf/httpd.conf에서 로그 형식 바꿈


CustomLog /usr/local/apache/logs/access_log 보통 이렇게 되어있는것을


SetEnvIfNoCase Request_URI (gif|png|jpg|css|js|bmp|jpeg|swf)$ IMAGE=1

CustomLog /usr/local/apache/logs/access_log combined env=!img-nosave,!CodeRedNimda


/usr/local/apache/bin/apachectl restart (아피치 리스타트)




실행 /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=firewolf.co.kr



실행시 오류 날때


[root@localhost awstats]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=115.68.74.148

Update for config "/etc/awstats/awstats.115.68.74.148.conf"

With data in log file "/usr/local/apache/logs/access_log"...

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/access_log must have a bad format or LogFormat parameter setup does not match this f                         ormat.

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):

66.249.75.113 - - [28/May/2015:12:02:58 +0900] "GET /store/shop/index.php?page=view_class&class_id=5606 HTTP/1.1" 404 218

Setup ('/etc/awstats/awstats.115.68.74.148.conf' file, web server or permissions) may be wrong.

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


로그 타입때문에 생기는 오류


#vi /etc/awstats/awstats.youmust.conf

LogFormat=”%host %other %logname %time1 %methodurl %code %bytesd”






[root@localhost awstats]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=115.68.74.148

Update for config "/etc/awstats/awstats.115.68.74.148.conf"

With data in log file "/usr/local/apache/logs/access_log"...

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

Direct access after last parsed record (after line 28)

Jumped lines in file: 28

 Found 28 already parsed records.

Parsed lines in file: 34

 Found 0 dropped records,

 Found 0 corrupted records,

 Found 0 old records,

 Found 34 new qualified records.


위같은 메시지가 나오면 성공!




crontab -e 

10 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=115.68.74.148





확인 http://자기 도메인/awstats/awstats.pl?config=자기 도메인




-----------------------------------------------------------------------------------------------------------------------


yum install awstats


cd /etc/awstats

cp awstats.localhost.localdomain.conf  ./awstats.naruman.com.conf


vi awstats.naruman.com.conf


LogFile="/logs/access.log"               // 아파치 로그

SiteDomain="naruman.com"            // 도메인 이름

DirData="/var/www/awstats"           // 데이터 디렉토리


기본에서 위 3개만 수정



vi /etc/httpd/conf.d/awstats.conf


allow from 127.0.0.1 을   -->  allow from all   변경




스크립트 작성


vi /root/script/awstatsupdate.sh


#!/bin/bash

exec /usr/bin/awstats_updateall.pl now -confdir="/etc" -awstatsprog="/var/www/awstats/awstats.pl" >/dev/null 

exit 0




vi /etc/crontab 등록


#awstats

*/5     *       *       *       *       root    /root/script/awstatsupdate.sh




naruman.com/awstats/awstats.pl


접속




 


출처 : https://www.linux.co.kr/home/lecture/?leccode=10641

'리눅스' 카테고리의 다른 글

도메인을 이용해 사용자 디렉토리 접속 방법  (0) 2015.07.01
make 명령어 옵션  (0) 2015.06.28
VI 문자열 치환  (0) 2015.06.22
fstab , mtab 이 삭제된 경우  (0) 2015.06.22
mrtg 설치하기  (0) 2015.06.20
Posted by Narusika
,