![]() |
◆ | 依存関係のインストール |
[root@centos]# dnf -y install perl perl-libwww-perl |
|
◆ | 依存関係のダウンロード&インストール |
ダウンロード | |
[root@centos]# wget http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/perl-Switch-2.17-10.el8.noarch.rpm |
|
インストール | |
[root@centos]# rpm -ivh perl-Switch-2.17-10.el8.noarch.rpm |
|
ダウンロードファイルの削除 | |
[root@centos]# rm -f perl-Switch-2.17-10.el8.noarch.rpm |
|
◆ | AWStatsのインストール |
[root@centos]# dnf --enablerepo=epel -y install awstats |
|
◆ | AWStatsの設定 |
AWStats をインストールすると awstats.<自ドメイン>.conf が自動生成されるので、それを編集 | |
[root@centos]# vi /etc/awstats/awstats.papa-net.info.conf 途中略 #----------------------------------------------------------------------------- # MAIN SETUP SECTION (Required to make AWStats work) #----------------------------------------------------------------------------- # "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). These are the 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 -cd /var/log/apache/access.log.gz |" # If there are several log files from load balancing servers : # Example: "/pathtotools/logresolvemerge.pl *.log |" LogFile="/var/log/httpd/mylog.log" <--- 書き換え(アクセスログの場所) ↓ LogFile="/var/log/httpd/www.papa-net.info-access_log" # Enter the log file type you want to analyze. # Possible values: # W - For a web log file <--- Webサーバー # S - For a streaming log file <--- ストリーミングサーバー # M - For a mail log file <--- メールサーバー # F - For an ftp log file <--- FTPサーバー # Example: W # Default: 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, with optional timezone specification (ignored) # %time6 Date and time with format: dd/mm/yyyy, hh: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 # If your log format has some literal strings, which precede data fields, use # status=%code Means your log files have HTTP status logged as "status=200" # Literal strings that follow data field must be separated from said data fields by space. # # 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 <--- 必要に応じて書き換え(1 = 複合 2 = 一般) 途中略 # "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="papa-net.info" <--- 自ドメインを確認 なっていない場合は書き換え # 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 a 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="REGEX[^.*papa-net\.info$]" <--- 自ドメインを確認 なっていない場合は書き換え # If you want to have hosts reported by name instead of ip address, AWStats # needs 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 # dramatically reduce AWStats's 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', 'geoipfree', or 'geoip2' # to have an accurate Country report with no need for DNS Lookup. # Possible values: # 0 - No DNS Lookup <--- DNSの逆引き(ホスト名を表示)を行わない # 1 - DNS Lookup is fully enabled <--- DNSの逆引き(ホスト名を表示)を行う # 2 - DNS Lookup is made only from static DNS cache file (if it exists) # Default: 2 ↑--- DNSの逆引き(ホスト名を表示)をキャッシュファイルから行う # DNSLookup=2 <--- 必要に応じて書き換え(上記の各数値を設定) 途中略 #----------------------------------------------------------------------------- # OPTIONAL SETUP SECTION (Not required but enhances AWStats's functionality) #----------------------------------------------------------------------------- 途中略 # Do not include access from clients that match following criteria. # If your log file contains IP addresses in host field, you must enter here # matching IP addresses criteria. # If DNS lookup is already done in your log file, you must enter here hostname # criteria, else enter ip address criteria. # The opposite parameter of "SkipHosts" is "OnlyHosts". # Note: Use space between each value. This parameter is not case sensitive. # Note: You can use regular expression values writing value with REGEX[value]. # Change : Effective for new updates only # Example: "127.0.0.1 REGEX[^192\.168\.] REGEX[^10\.]" # Example: "localhost REGEX[^.*\.localdomain$]" # Default: "" # SkipHosts="127.0.0.1" <--- 書き換え(ローカルLAN内だけにアクセス許可) ↓ SkipHosts="127.0.0.1 REGEX[^192\.168\.1\.]" 以下略 |
|
◆ | awstats 用 apache の設定 |
[root@centos]# vi /etc/httpd/conf.d/awstats.conf # # Content of this file, with correct values, can be automatically added to # your Apache server by using the AWStats configure.pl tool. # # If using Windows and Perl ActiveStat, this is to enable Perl script as CGI. #ScriptInterpreterSource registry # # Directives to add to your Apache conf file to allow use of AWStats as a CGI. # Note that path "/usr/share/awstats/" must reflect your AWStats install path. # Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/" Alias /awstatscss "/usr/share/awstats/wwwroot/css/" Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/" ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/" # # This is to permit URL access to scripts/files in AWStats directory. # <Directory "/usr/share/awstats/wwwroot"> Options None AllowOverride None <IfModule mod_authz_core.c> # Apache 2.4 Require local <--- 書き換え(ローカルLAN内だけにアクセス許可) ↓ Require ip 127.0.0.1 192.168.1.0/24 </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order allow,deny Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory> # Additional Perl modules <IfModule mod_env.c> SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins </IfModule> |
|
◆ | httpd ファイルの構文チェック |
[root@centos]# httpd -t Syntax OK <--- Syntax OK になっていればOK |
|
◆ | Apache の再起動 |
[root@centos]# systemctl restart httpd |
|
◆ | Webサーバー(apache)用ログ解析出力用HTMLファイルの作成 |
[root@centos]# /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=papa-net.info -update Create/Update database for config "/etc/awstats/awstats.papa-net.info.conf" by AWStats version 7.8 (build 20200416) From data in log file "/var/log/httpd/www.papa-net.info-access_log"... Phase 1 : First bypass old records, searching new record... Direct access to last remembered record is out of file. So searching it from beginning of log file... Jumped lines in file: 0 Parsed lines in file: 0 Found 0 dropped records, Found 0 comments, Found 0 blank records, Found 0 corrupted records, Found 0 old records, Found 0 new qualified records. |
|
◆ | Webサーバー(apache)用解析結果のブラウザ表示 |
http://サーバーのIPアドレス(ドメイン名)/awstats/awstats.pl?config=papa-net.info にアクセスすると下図のように解析結果が表示 | |
|
|