티스토리 뷰

awstats는 perl로 작성된 CGI이다.

따라서 apache에서 perl을 실핼할 수 있어야 한다.

그런데 apache v2.4.x에서는 cgi-script로서 perl을 지원하지 못하는 것 같다.

mod_perl 모듈을 추가해서 구성하려고해서 apache v2.4.x를 지원하는 mod_perl을 현재(2013.11.06)까지 나오지 않은 것 같다.

따라서 awstats를 사용하고자 한다면 apache v2.2.x 를 사용해야 한다.

 

cronolog나 retatelogs를 통해서 apache 로그를 순환하더라도 awstats에서 httpd.conf 파일을 확인해서 해당 도메인별로 apache 로그를 찾아 통계를 생성한다.

 

cronolog 는 이전에 작성한 내용을 참고한다.

 

우선 httpd.conf 를 확인해보자

 

<VirtualHost *:80>
    ServerAdmin webmaster@boanhack.com
    DocumentRoot "/usr/local/server/apache/htdocs"
    ServerName boanhack.com
    ServerAlias www.boanhack.com
    ErrorLog "|/usr/local/server/cronolog/sbin/cronolog /usr/local/server/apache/logs/boanhack/access_log/%Y/%m/access_log_%Y%m%d"
    CustomLog "|/usr/local/server/cronolog/sbin/cronolog /usr/local/server/apache/logs/boanhack/access_log/%Y/%m/access_log_%Y%m%d" combined env=!image
</VirtualHost>

 

위에서는 cronolog를 통해서 apache로그를 순환시키고 있다.

 

awstats를 받아서 설치해보자.

 

http://www.awstats.org/

 

복사할 때 가능하면 /usr/local/awstats 경로를 지켜주는게 좋다.

다른 곳에 복사하면 변경해주어야하는 파일일 좀 많다...

 

# tar zxvf awstats-7.2.tar.gz

# mv awstats-7.2 /usr/local/awstats

# cd /usr/local/awstats/tools

# perl awstats_configure.pl

-----> Running OS detected: Linux, BSD or Unix
Warning: AWStats standard directory on Linux OS is '/usr/local/awstats'.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/usr/local/server/awstats
to standard directory:
/usr/local/awstats
And then, run configure.pl from this location.
Do you want to continue setup from this NON standard directory [yN] ? y

 

처음 설치하는 것이기에 yes.

 

-----> Check for web server install

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
> /usr/local/server/apache/conf/httpd.conf

-----> Check and complete web server config file '/usr/local/server/apache/conf/httpd.conf'
  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

 

httpd.conf 설정을 추가하며 필요한 파일들을 생성하고 있다.

처음 설치냐고 물어본다.. yes.

 

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

 

사이트를 적으라고 되어 있는데, 나중에 도메인별로 확인할 때 사용하므로 사이트별로 구분하기 쉬운 값으로 주면 된다.

 

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

 

설정파일 위치를 물어본다. 좀 전에 입력한 사이트명 기준으로 생성된 설정 파일 위치를 설정하는 것이다.

그냥 기본으로... Enter

 

-----> Create config file '/etc/awstats/awstats.boanhack.conf'
 Config file /etc/awstats/awstats.boanhack.conf created.

-----> Restart Web server with '/sbin/service httpd restart'
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message

-----> 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=boanhack
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..

 

/etc/awstats 밑에 설정파일을 생성했으며 아파치를 재구동했다.

그리고 설정파일에 맞추어서 boanhack 정보를 업데이트했다.

awstats 설치 전에 아파치 로그가 많다면 수동으로 업데이트를 더 해주는게 좋을 것 같다....Enter

 

A SIMPLE config file has been created: /etc/awstats/awstats.boanhack.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'boanhack' with command:
> perl awstats.pl -update -config=boanhack
You can also read your statistics for 'boanhack' with URL:
> http://localhost/awstats/awstats.pl?config=boanhack

Press ENTER to finish...

 

기본 설정 파일을 만들어졌다....Enter

 

/etc/awstats

/var/lib/awstats

/usr/local/awstats/wwwroot/cgi-bin

 

혹시나 위 디렉터리가 없다고 생성해 주자.

 

#mkdir /var/lib/awstats

 

생성된 설정파일을 수정해보자.

 

# vi /etc/awstats/awstats.boanhack.conf

.....

# "LogFile" contains the web, ftp or mail server log file to analyze.
# Possible values: A full path, or a relative path from awstats.pl directory.
# Example: "/var/log/apache/access.log"
# Example: "../logs/mycombinedlog.log"
# You can also use tags in this filename if you need a dynamic file name
# depending on date or time (Replacement is made by AWStats at the beginning
# of its execution). This is available tags :
#   %YYYY-n  is replaced with 4 digits year we were n hours ago
#   %YY-n    is replaced with 2 digits year we were n hours ago
#   %MM-n    is replaced with 2 digits month we were n hours ago
#   %MO-n    is replaced with 3 letters month we were n hours ago
#   %DD-n    is replaced with day we were n hours ago
#   %HH-n    is replaced with hour we were n hours ago
#   %NS-n    is replaced with number of seconds at 00:00 since 1970
#   %WM-n    is replaced with the week number in month (1-5)
#   %Wm-n    is replaced with the week number in month (0-4)
#   %WY-n    is replaced with the week number in year (01-52)
#   %Wy-n    is replaced with the week number in year (00-51)
#   %DW-n    is replaced with the day number in week (1-7, 1=sunday)
#                              use n=24 if you need (1-7, 1=monday)
#   %Dw-n    is replaced with the day number in week (0-6, 0=sunday)
#                              use n=24 if you need (0-6, 0=monday)
#   Use 0 for n if you need current year, month, day, hour...
# Example: "/var/log/access_log.%YYYY-0%MM-0%DD-0.log"
# Example: "C:/WINNT/system32/LogFiles/W3SVC1/ex%YY-24%MM-24%DD-24.log"
# You can also use a pipe if log file come from a pipe :
# Example: "gzip -d </var/log/apache/access.log.gz |"
# If there are several log files from load balancing servers :
# Example: "/pathtotools/logresolvemerge.pl *.log |"
#
LogFile="/usr/local/server/apache/logs/boanhack/access_log/%YYYY/%MM/access_log_%YYYY%MM%DD"

 

cronolog에서 설정한 파일을 기준으로 LogFile을 설정한다.

%YYYY, %MM, %DD 뒤에 -숫자를 주면 그 값을 뺀 값까지 검색한다고 한다.

%YYYY-2를 하면 현재 년도를 기준으로 2년전까지 확인하다는 말이 된다.

이전 로그가 많지 않다면 굳이 해 줄 필요는 없을 듯핟.

그러나 과거 로그까지 통계를 내고자 한다면 초기에만 설정하고 통계 이 후에는 빼면 될 듯...

 

 

# Enter the log file type you want to analyze.
# Possible values:
#  W - For a web log file
#  S - For a streaming log file
#  M - For a mail log file
#  F - For a ftp log file
# Example: W
# Default: W
#
LogType=W

 

웹로그를 분석하므로 당연히 LogType 값은 'W'

 

# Enter here your log format (Must match your web server config. See setup
# instructions in documentation to know how to configure your web server to
# have the required log format).
# Possible values: 1,2,3,4 or "your_own_personalized_log_format"
# 1 - Apache or Lotus Notes/Domino native combined log format (NCSA combined/XLF/ELF log format)
# 2 - IIS or ISA format (IIS W3C log format). See FAQ-COM115 For ISA.
# 3 - Webstar native log format.
# 4 - Apache or Squid native common log format (NCSA common/CLF log format)
#     With LogFormat=4, some features (browsers, os, keywords...) can't work.
# "your_own_personalized_log_format" = If your log is ftp, mail or other format,
#     you must use following keys to define the log format string (See FAQ for
#     ftp, mail or exotic web log format examples):
#   %host             Client hostname or IP address (or Sender host for mail log)
#   %host_r           Receiver hostname or IP address (for mail log)
#   %lognamequot      Authenticated login/user with format: "john"
#   %logname          Authenticated login/user with format: john
#   %time1            Date and time with format: [dd/mon/yyyy:hh:mm:ss +0000] or [dd/mon/yyyy:hh:mm:ss]
#   %time2            Date and time with format: yyyy-mm-dd hh:mm:ss
#   %time3            Date and time with format: Mon dd hh:mm:ss or Mon dd hh:mm:ss yyyy
#   %time4            Date and time with unix timestamp format: dddddddddd
#   %time5            Date and time with format iso: yyyy-mm-ddThh:mm:ss
#   %methodurl        Method and URL with format: "GET /index.html HTTP/x.x"
#   %methodurlnoprot  Method and URL with format: "GET /index.html"
#   %method           Method with format: GET
#   %url              URL only with format: /index.html
#   %query            Query string (used by URLWithQuery option)
#   %code             Return code status (with format for web log: 999)
#   %bytesd           Size of document in bytes
#   %refererquot      Referer page with format: "http://from.com/from.htm"
#   %referer          Referer page with format: http://from.com/from.htm
#   %uabracket        User agent with format: [Mozilla/4.0 (compatible, ...)]
#   %uaquot           User agent with format: "Mozilla/4.0 (compatible, ...)"
#   %ua               User agent with format: Mozilla/4.0_(compatible...)
#   %gzipin           mod_gzip compression input bytes: In:XXX
#   %gzipout          mod_gzip compression output bytes & ratio: Out:YYY:ZZpct.
#   %gzipratio        mod_gzip compression ratio: ZZpct.
#   %deflateratio     mod_deflate compression ratio with format: (ZZ)
#   %email            EMail sender (for mail log)
#   %email_r          EMail receiver (for mail log)
#   %virtualname      Web sever virtual hostname. Use this tag when same log
#                     contains data of several virtual web servers. AWStats
#                     will discard records not in SiteDomain nor HostAliases
#   %cluster          If log file is provided from several computers (merged by
#                     logresolvemerge.pl), use this to define cluster id field.
#   %extraX           Another field that you plan to use for building a
#                     personalized report with ExtraSection feature (See later).
#   If your log format has some fields not included in this list, use:
#   %other            Means another not used field
#   %otherquot        Means another not used double quoted field
#
# Examples for Apache combined logs (following two examples are equivalent):
# LogFormat = 1
# LogFormat = "%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot"
#
# Example for IIS:
# LogFormat = 2
#
LogFormat=1

 

아파치 로그를 설정하므로 LogFormat는 '1'로 설정

 

# "SiteDomain" must contain the main domain name, or the main intranet web
# server name, used to reach the web site.
# If you share the same log file for several virtual web servers, this
# parameter is used to tell AWStats to filter record that contains records for
# this virtual host name only (So check that this virtual hostname can be
# found in your log file and use a personalized log format that include the
# %virtualname tag).
# But for multi hosting a better solution is to have one log file for each
# virtual web server. In this case, this parameter is only used to generate
# full URL's links when ShowLinksOnUrl option is set to 1.
# If analyzing mail log, enter here the domain name of mail server.
# Example: "myintranetserver"
# Example: "www.domain.com"
# Example: "ftp.domain.com"
# Example: "domain.com"
#
SiteDomain="boanhack.com"

 

도메인 값은 virthalhost에서 설정한 ServerName으로 설정한다.

awstats 설정 파일을 만들 때 사이트명에 ServerName을 입력했다면 따로 수정할 필요는 없을 것 같다.

 

# Enter here all other possible domain names, addresses or virtual host
# aliases someone can use to access your site. Try to keep only the minimum
# number of possible names/addresses to have the best performances.
# You can repeat the "SiteDomain" value in this list.
# This parameter is used to analyze referer field in log file and to help
# AWStats to know if a referer URL is a local URL of same site or an URL of
# another site.
# Note: Use space between each value.
# Note: You can use regular expression values writing value with REGEX[value].
# Note: You can also use @/mypath/myfile if list of aliases are in a file.
# Example: "www.myserver.com localhost 127.0.0.1 REGEX[mydomain\.(net|org)$]"
#
HostAliases="boanhack.com www.boanhack.com 127.0.0.1 localhost"

 

HostAliases 또한 사이트명에 ServerName을 입력했다면 따로 수정할 필요는 없을 듯하다.

ServerName을 입력하지 않았다면 ServerName, ServerAlias 값을 입력해 주면 된다.

 

# If you want to have hosts reported by name instead of ip address, AWStats
# need to make reverse DNS lookups (if not already done in your log file).
# With DNSLookup to 0, all hosts will be reported by their IP addresses and
# not by the full hostname of visitors (except if names are already available
# in log file).
# If you want/need to set DNSLookup to 1, don't forget that this will reduce
# dramatically AWStats update process speed. Do not use on large web sites.
# Note: Reverse DNS lookup is done on IPv4 only (Enable ipv6 plugin for IPv6).
# Note: Result of DNS Lookup can be used to build the Country report. However
# it is highly recommanded to enable the plugin 'geoip' or 'geoipfree' to
# have an accurate Country report with no need of DNS Lookup.
# Possible values:
# 0 - No DNS Lookup
# 1 - DNS Lookup is fully enabled
# 2 - DNS Lookup is made only from static DNS cache file (if it exists)
# Default: 2
#
DNSLookup=0

 

DNS lookup을 사용하지 않도록 설정.

 

# When AWStats updates its statistics, it stores results of its analysis in
# files (AWStats database). All those files are written in the directory
# defined by the "DirData" parameter. Set this value to the directory where
# you want AWStats to save its database and working files into.
# Warning: If you want to be able to use the "AllowToUpdateStatsFromBrowser"
# feature (see later), you need "Write" permissions by web server user on this
# directory (and "Modify" for Windows NTFS file systems).
# Example: "/var/lib/awstats"
# Example: "../data"
# Example: "C:/awstats_data_dir"
# Default: "."          (means same directory as awstats.pl)
#
DirData="/var/lib/awstats"

 

생성한 통계 데이터가 쌓이는 곳이다. 그냥 기본으로 사용하자.

 

# When this parameter is set to 1, AWStats adds a button on report page to
# allow to "update" statistics from a web browser. Warning, when "update" is
# made from a browser, AWStats is run as a CGI by the web server user defined
# in your web server (user "nobody" by default with Apache, "IUSR_XXX" with
# IIS), so the "DirData" directory and all already existing history files
# awstatsMMYYYY[.xxx].txt must be writable by this user. Change permissions if
# necessary to "Read/Write" (and "Modify" for Windows NTFS file systems).
# Warning: Update process can be long so you might experience "time out"
# browser errors if you don't launch AWStats frequently enough.
# When set to 0, update is only made when AWStats is run from the command
# line interface (or a task scheduler).
# Possible values: 0 or 1
# Default: 0
#
AllowToUpdateStatsFromBrowser=0

 

웹에서도 통계 데이터 업데이트를 할 수 있도록 하는 설정이다.

그러나 awstats 디렉터리에 스크립트 실행 권한을 주어야 하므로 보안상 좋지는 않은 것 같다.

crontab을 사용해서 통계 데이터를 업데이트 할 것이므로 웹에서는 실행하지 말자.

 

 

# Set your primary language (ISO-639-1 language codes).
# Possible values:
#  Albanian=al, Bosnian=ba, Bulgarian=bg, Catalan=ca,
#  Chinese (Taiwan)=tw, Chinese (Simpliefied)=cn, Croatian=hr, Czech=cz,
#  Danish=dk, Dutch=nl, English=en, Estonian=et, Euskara=eu, Finnish=fi,
#  French=fr, Galician=gl, German=de, Greek=gr, Hebrew=he, Hungarian=hu,
#  Icelandic=is, Indonesian=id, Italian=it, Japanese=jp, Korean=ko,
#  Latvian=lv, Norwegian (Nynorsk)=nn, Norwegian (Bokmal)=nb, Polish=pl,
#  Portuguese=pt, Portuguese (Brazilian)=br, Romanian=ro, Russian=ru,
#  Serbian=sr, Slovak=sk, Slovenian=si, Spanish=es, Swedish=se, Turkish=tr,
#  Ukrainian=ua, Welsh=cy.
#  First available language accepted by browser=auto
# Default: "auto"
#
Lang="ko"

 

한글을 지원하도록 설정해보자.

 

awstats 를 실행해서 통계 데이터를 업데이트 해 보자.

 

# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=boanhack -update

Create/Update database for config "/etc/awstats/awstats.boanhack.conf" by AWStats version 7.2 (build 1.992)
From data in log file "/usr/local/server/apache/logs/boanhack/access_log/2013/10/access_log_20131030"...
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: 20
 Found 0 dropped records,
 Found 0 comments,
 Found 0 blank records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 20 new qualified records.

 

awstats 를 설치 테스트를 위해 임시로 만든 사이트라서 로그가 많지는 않다.

 

매 10분마다 도메인별로 통계 업데이트를 위해서 crontab에 스크립트를 저장하자.

 

# crontab -e
no crontab for root - using an empty one
*/10 * * * *    root    perl /usr/local/awstats/tools/awstats_updateall.pl now >/dev/null 2>&1

 

 

웹에서 확인할 수 있도록 httpd.conf 를 다시 확인해보자

아래 내용이 들어가 있는지 확인해보자.

 

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.
#
<Directory "/usr/local/awstats/wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

 

위에서처럼 httpd.conf 에 설정하지 않고 httpd_vhosts.conf 에 설정해서 적용해도 된다.

그리고 도메인을 하나 추가해서 해당 도메인 VirtualHost 에 넣어 주어서 전용 URL 처럼 사용해도 된다.

아래와 같이 적용하면 될 것 같다.

 

<VirtualHost *:80>
    ServerAdmin webmaster@boanhack.com
    DocumentRoot "/usr/local/awstats/wwwroot"
    ServerName stats.boanhack.com
    ErrorLog "|/usr/local/server/cronolog/sbin/cronolog /usr/local/server/apache/logs/boanhack/error_log/%Y/%m/error_log_%Y%m%d"
    CustomLog "|/usr/local/server/cronolog/sbin/cronolog /usr/local/server/apache/logs/boanhack/access_log/%Y/%m/access_log_%Y%m%d" combined env=!image
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/"

<Directory "/usr/local/awstats/wwwroot">
    Options None
    AllowOverride none
    Order allow,deny
    Allow from all
</Directory>

<Location /awstats>
AuthName "awstats 통계"
AuthType Basic
AuthUserFile /usr/local/server/apache/.boanhack_htpasswd
ErrorDocument 401 "인증되지 않았습니다."
ErrorDocument 403 "/error.html"
<LIMIT GET POST>
    satisfy all
    SetEnvIfNoCase remote_addr 192.168.0. boanhack

    SetEnvIfNoCase remote_addr 192.168.1.0/24 boanhack
    order deny,allow
    allow from env=boanhack
    deny from all
    require valid-user
</LIMIT>
</Location>

</VirtualHost>

 

 

 

GeoIP 연동하기

 

http://dev.maxmind.com/geoip/legacy/geolite/

 

위에서 GeoLite Country와 GeoLite City 파일을 다운로드한다.

 

http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

 

GeoIP.dat.gz

 

GeoLiteCity.dat.gz

(2013.11.06 기준)

 

[root@centos /]# mkdir /usr/local/share/GeoIP
[root@centos /]# mv Geo* /usr/local/share/GeoIP/
[root@centos /]# cd /usr/local/share/GeoIP
[root@centos GeoIP]# gunzip ./*
[root@centos GeoIP]# ls

GeoIP.dat  GeoLiteCity.dat

 

GeoIP C source 및 Geo-IP-PurePerl 파일을 받아서 컴파일

통계 정보를 업데이트 할 때 pureperl을 찾기 때문이다.

설치하면서 mod_geoip도 같이 설치해보자

 

Geo-IP-PurePerl-1.25.tar.gz

 

GeoIP-1.6.0.tar.gz

 

mod_geoip2-1.2.8.tar.gz

(2013.11.06 기준)

[root@centos server]# tar zxvf GeoIP-1.6.0.tar.gz
GeoIP-1.6.0/
GeoIP-1.6.0/LICENSE
GeoIP-1.6.0/INSTALL
GeoIP-1.6.0/libGeoIP/
GeoIP-1.6.0/libGeoIP/Makefile.in
GeoIP-1.6.0/libGeoIP/Makefile.vc
GeoIP-1.6.0/libGeoIP/regionName.c
GeoIP-1.6.0/libGeoIP/GeoIP_internal.h

.....

 

[root@centos server]# cd GeoIP-1.6.0
[root@centos GeoIP-1.6.0]# ./configure

[root@centos GeoIP-1.6.0]# make && make intall

 

[root@centos server]# tar zxvf Geo-IP-PurePerl-1.25.tar.gz

[root@centos server]# cd Geo-IP-PurePerl-1.25
[root@centos Geo-IP-PurePerl-1.25]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Geo::IP::PurePerl
[root@centos Geo-IP-PurePerl-1.25]# make
cp lib/Geo/IP/PurePerl.pm blib/lib/Geo/IP/PurePerl.pm
cp geoip-lookup blib/script/geoip-lookup
/usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/geoip-lookup
Manifying blib/man1/geoip-lookup.1
Manifying blib/man3/Geo::IP::PurePerl.3pm
[root@centos Geo-IP-PurePerl-1.25]# make install
Installing /usr/lib/perl5/site_perl/5.8.8/Geo/IP/PurePerl.pm
Installing /usr/share/man/man1/geoip-lookup.1
Installing /usr/share/man/man3/Geo::IP::PurePerl.3pm
Installing /usr/bin/geoip-lookup
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Geo/IP/PurePerl/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
[root@centos Geo-IP-PurePerl-1.25]#

 

[root@centos server]# tar zxvf mod_geoip2-1.2.8.tar.gz
mod_geoip2_1.2.8/
mod_geoip2_1.2.8/Changes
mod_geoip2_1.2.8/INSTALL
mod_geoip2_1.2.8/mod_geoip.c
mod_geoip2_1.2.8/README
mod_geoip2_1.2.8/README.php

....

 

[root@centos server]# cd mod_geoip2_1.2.8/
[root@centos mod_geoip2_1.2.8]# apxs -i -a -L/usr/local/lib -I/usr/local/include -lGeoIP -c mod_geoip.c

/usr/local/server/apr/build-1/libtool --silent --mode=compile gcc -prefer-pic   -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -g -O2 -pthread -I/usr/local/server/apache/include  -I/usr/local/server/apr/include/apr-1   -I/usr/local/server/apr-util/include/apr-1  -I/usr/local/include  -c -o mod_geoip.lo mod_geoip.c && touch mod_geoip.slo
/usr/local/server/apr/build-1/libtool --silent --mode=link gcc -o mod_geoip.la  -L/usr/local/lib -lGeoIP -rpath /usr/local/server/apache/modules -module -avoid-version    mod_geoip.lo
/usr/local/server/apache/build/instdso.sh SH_LIBTOOL='/usr/local/server/apr/build-1/libtool' mod_geoip.la /usr/local/server/apache/modules
/usr/local/server/apr/build-1/libtool --mode=install cp mod_geoip.la /usr/local/server/apache/modules/
libtool: install: cp .libs/mod_geoip.so /usr/local/server/apache/modules/mod_geoip.so
libtool: install: cp .libs/mod_geoip.lai /usr/local/server/apache/modules/mod_geoip.la
libtool: install: cp .libs/mod_geoip.a /usr/local/server/apache/modules/mod_geoip.a
libtool: install: chmod 644 /usr/local/server/apache/modules/mod_geoip.a
libtool: install: ranlib /usr/local/server/apache/modules/mod_geoip.a
libtool: finish: PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/server/mysql/bin:/usr/local/server/apache/bin:/sbin" ldconfig -n /usr/local/server/apache/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/server/apache/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/local/server/apache/modules/mod_geoip.so
[activating module `geoip' in /usr/local/server/apache/conf/httpd.conf]

 

apache/modules 밑에 mpd_geoip.so 있는지 확인

 

[root@centos mod_geoip2_1.2.8]# ls /usr/local/server/apache/modules/mod_geo*
/usr/local/server/apache/modules/mod_geoip.so

 

httpd.conf 에 아래 내용 추가 되었는지 확인

...

LoadModule php5_module        modules/libphp5.so
LoadModule geoip_module       modules/mod_geoip.so

....

 

 

/etc/awstats_도메인명 conf 파일을 열어서 아래 내용을 추가한다.

 

# Plugin: GeoIP
LoadPlugin=”geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat”

 

# Plugin: GeoIP_City_Maxmind
LoadPlugin=”geoip_city_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoLiteCity.dat”

 

 

국내 검색 엔진 추가

 

[root@centos lib]# vi /usr/local/awstats/wwwroot/cgi-bin/lib/search_engines.pm

@SearchEnginesSearchIDOrder_list1=(
# Major international search engines
# Korean search engines
'search\.naver\.',
'search\.daum\.',
'search\.nate\.',

'google\.[\w.]+/products',
'base\.google\.',
'froogle\.google\.',
'groups\.google\.',

......

 

위 내용은 어떤 URL을 통해서 들어오는지 확인하는 것이다.

search\.naver\. 은 URL에서 search.naver~로 시작하는 것을 확인하라는 것이다.

 

 

%SearchEnginesHashID = (
# Major international search engines
# Korean search engines
'search.naver.','naver',
'search.daum.','daum',
'search.nate.','nate',

'google\.[\w.]+/products','google_products',
'base\.google\.','google_base'

.......

 

위 내용은 들어오는 URL에 대한 고유 Hash ID를 지정하는 것이다.

 

 

%SearchEnginesKnownUrl=(
# Most common search engines
# 네이버 http://search.naver.com/search.naver?query=
# 다음    http://search.daum.net/search?q=
# 네이트 http://search.nate.com/search/all.html?q=
# Korean search engines
'naver','query=',
'daum','q=',
'nate','q=',

'alexa','q=',
'alltheweb','q(|uery)=',

.......

 

위 내용은 해당 URL에 포함된 검색 인자를 확인하는 것이다.

 

 

%SearchEnginesHashLib=(
# Major international search engines
# Korean search engines
'naver','<a href="http://www.naver.com/" title="Naver Home Page" target="_blank">Naver</a>',
'daum','<a href="
http://www.daum.net/" title="Daum Home Page" target="_blank">Daum</a>',
'nate','<a href="
http://www.nate.com/" title="Nate Home Page" target="_blank">Nate</a>',
'alexa','<a href="http://www.alexa.com/" title="Search Engine Home Page [new window]" target="_blank">Alexa</a>',
'alltheweb','<a href="http://www.alltheweb.com/" title="Search Engine Home Page [new window]" target="_blank">AllTheWeb</a>',

 

위 내용은 결과를 보여줄 때 Title이라고 보면 될 것 같다.

 

 

 

 

설정 후 awstats를 업데이트 한다.

 

아래와 같은 형식의 URL과 awstats 설정도메인명을 입력하면 화면이 출력된다.

 

http://www.boanhack.com/awstats/awstats.pl?config=boanhack

 

 

통계 데이터 HTML 출력하기

 

 

/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=boanhack.com -dir=/usr/local/server/apache/htdocs/ -update

 

awstats tools 밑에 있는 awstats_buildstaticpages.pl 을 통해서 HTML 형식으로 export가 가능하다.

 

-dir : HTML 파일을 저장할 디렉터리, 여러 개 도메인이라면 해단 도메인이 속한 디렉터리로 출력해도 좋을 듯..

-update : 통계 데이터를 export 시키기 전에 awstats.pl update 후에 HTML export 시킴

'Study > System' 카테고리의 다른 글

apache error  (0) 2013.11.08
apache SetEnvIf  (0) 2013.11.08
cronolog를 통한 Apache 로그 일자별로 저장하기  (0) 2013.10.29
웹사이트 페이지 로딩 모니터링용 스크립트  (0) 2013.07.22
sshd_config 설정  (0) 2013.07.22
댓글