#author("2018-08-27T15:35:05+09:00","","")

#author("2018-08-27T15:39:17+09:00","","")

[[CentOS7]]

*AWStatsインストール [#vba06d01]
''[[AWStats>http://awstats.sourceforge.net/]]''を利用して''Apache''のアクセスログを解析し、''Web''サイトへのアクセス統計を''Web''ブラウザから参照できるようにする。



*AWStatsインストール [#j46a2b96]
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# wget http://prdownloads.sourceforge.net/awstats/awstats-7.3-1.noarch.rpm &color(lime){← AWStatsダウンロード};|
|&color(lightpink){※最新版のURLは[[ダウンロードページ>http://www.awstats.org/#DOWNLOAD]]で確認すること};|
|[root@localhost ~]# rpm -ivh awstats-7.3-1.noarch.rpm &color(lime){← AWStatsインストール};|
|[root@localhost ~]# rm -f awstats-7.3-1.noarch.rpm &color(lime){← ダウンロードしたファイルを削除};|
|[root@localhost ~]# vi `rpm -ql awstats | grep "awstats\.pl"` &color(lime){← awstats.pl編集};|
|&color(lightpink){※レポートの日付形式を「月 2月 2010」から「2010年 2月」へ変更}; &br;                                 if ( $MonthRequired eq 'all' ) { &br;                                         print "$Message[6] $YearRequired"; &br;                                 } &br;                                 else { &br;                                         print &br;                                           &color(lime){#};"$Message[5] $MonthNumLib{$MonthRequired} $YearRequired"; &color(lime){← 行頭に&color(lime){#};を追加してコメントアウト}; &br;                                           "$YearRequired$Message[6] ".$MonthNumLib{$MonthRequired}; &color(lime){← 追加(日付をYYYY年 MM月形式にする)}; &br;                                 } &br;  &br;                         print( $MonthRequired eq 'all' &br;                                 ? "$Message[6] $YearRequired" &br;                                 &color(lime){#};: "$Message[5] " &color(lime){← 行頭に&color(lime){#};を追加してコメントアウト}; &br;                                   &color(lime){#};. $MonthNumLib{$MonthRequired} &color(lime){← 行頭に&color(lime){#};を追加してコメントアウト}; &br;                                   &color(lime){#};. " $YearRequired" &color(lime){← 行頭に&color(lime){#};を追加してコメントアウト}; &br;                                 : "$YearRequired$Message[6] $MonthNumLib{$MonthRequired}" &color(lime){← 追加(日付をYYYY年 MM月形式にする)}; &br;                         ); &br;  &br;                                         &color(lime){#};print "$MonthNumLib{$monthix}<br />$YearRequired"; &color(lime){← 行頭に#を追加してコメントアウト}; &br;                                         print "$YearRequired$Message[6]<br />$MonthNumLib{$monthix}"; &color(lime){← 追加(日付をYYYY年 MM月形式にする)}; &br;  &br;                                         &color(lime){#};print "$MonthNumLib{$monthix} $YearRequired"; &color(lime){← 行頭に#を追加してコメントアウト}; &br;                                         print "$YearRequired$Message[6] $MonthNumLib{$monthix}"; &color(lime){← 追加(日付をYYYY年 MM月形式にする)};|

|&color(lightpink){※レポートの日付形式を「2月 2010年」から「2010年 2月」へ変更}; &br;                                 if ( $MonthRequired eq 'all' ) { &br;                                         print "$Message[6] $YearRequired"; &br;                                 } &br;                                 else { &br;                                         print &br;                                           &color(lime){#};"$Message[5] $MonthNumLib{$MonthRequired} $YearRequired"; &color(lime){← 行頭に&color(lime){#};を追加してコメントアウト}; &br;                                           "$YearRequired$Message[6] ".$MonthNumLib{$MonthRequired}; &color(lime){← 追加(日付をYYYY年 MM月形式にする)}; &br;                                 } &br;  &br;                         print( $MonthRequired eq 'all' &br;                                 ? "$Message[6] $YearRequired" &br;                                 &color(lime){#};: "$Message[5] " &color(lime){← 行頭に&color(lime){#};を追加してコメントアウト}; &br;                                   &color(lime){#};. $MonthNumLib{$MonthRequired} &color(lime){← 行頭に&color(lime){#};を追加してコメントアウト}; &br;                                   &color(lime){#};. " $YearRequired" &color(lime){← 行頭に&color(lime){#};を追加してコメントアウト}; &br;                                 : "$YearRequired$Message[6] $MonthNumLib{$MonthRequired}" &color(lime){← 追加(日付をYYYY年 MM月形式にする)}; &br;                         ); &br;  &br;                                         &color(lime){#};print "$MonthNumLib{$monthix}<br />$YearRequired"; &color(lime){← 行頭に#を追加してコメントアウト}; &br;                                         print "$YearRequired$Message[6]<br />$MonthNumLib{$monthix}"; &color(lime){← 追加(日付をYYYY年 MM月形式にする)}; &br;  &br;                                         &color(lime){#};print "$MonthNumLib{$monthix} $YearRequired"; &color(lime){← 行頭に#を追加してコメントアウト}; &br;                                         print "$YearRequired$Message[6] $MonthNumLib{$monthix}"; &color(lime){← 追加(日付をYYYY年 MM月形式にする)};|




*AWStats設定 [#y3a67aba]
**AWStats設定 [#w3f62219]
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# touch /etc/httpd/conf.d/awstats.conf &color(lime){← ''Apache''用''AWStats''設定ファイル作成};|
|[root@localhost ~]# cd /usr/local/awstats/ &color(lime){← ''AWStats''設定スクリプト格納ディレクトリへ移動};|
|[root@localhost awstats]# perl /usr/local/awstats/tools/awstats_configure.pl &color(lime){← ''AWStats''設定スクリプト実行};|
|----- AWStats awstats_configure 1.0 (build 20140126) (c) Laurent Destailleur ----- &br; This tool will help you to configure AWStats to analyze statistics for &br; one web server. You can try to use it to let it do all that is possible &br; in AWStats setup, however following the step by step manual setup &br; documentation (docs/index.html) is often a better idea. Above all if: &br; - You are not an administrator user, &br; - You want to analyze downloaded log files without web server, &br; - You want to analyze mail or ftp log files instead of web log files, &br; - You need to analyze load balanced servers log files, &br; - You want to 'understand' all possible ways to use AWStats... &br; Read the AWStats documentation (docs/index.html). &br;  &br; -----> Running OS detected: Linux, BSD or Unix &br;  &br; -----> Check for web server install &br;  &br; Enter full config file path of your Web server. &br; Example: /etc/httpd/httpd.conf &br; Example: /usr/local/apache2/conf/httpd.conf &br; Example: c:\Program files\apache group\apache\conf\httpd.conf &br; Config file path ('none' to skip web server setup): &br; > /etc/httpd/conf.d/awstats.conf ← Apache用AWStats設定ファイル名応答 &br;  &br; -----> Check and complete web server config file '/etc/httpd/conf.d/awstats.conf' &br;   Add 'Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"' &br;   Add 'Alias /awstatscss "/usr/local/awstats/wwwroot/css/"' &br;   Add 'Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"' &br;   Add 'ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"' &br;   Add '' directive &br;   AWStats directives added to Apache config file. &br;  &br; -----> Update model config file '/etc/awstats/awstats.model.conf' &br;   File awstats.model.conf updated. &br;  &br; -----> Need to create a new config file ? &br; Do you want me to build a new AWStats config/profile &br; file (required if first install) [y/N] ? &color(lightpink){y}; &color(lime){← y応答(AWStats設定ファイル作成)}; &br;  &br; -----> Define config file name to create &br; What is the name of your web site or profile analysis ? &br; Example: www.mysite.com &br; Example: demo &br; Your web site, virtual server or profile name: &br; > hoge.com &color(lime){← サイト名応答(例:hoge.com)}; &br;  &br; -----> Define config file path &br; In which directory do you plan to store your config file(s) ? &br; Default: /etc/awstats &br; Directory path to store config file(s) (Enter for default): &br; > &color(lime){← 空ENTER(AWStats設定ファイル作成先はデフォルト=/etc/awstats)}; &br;  &br; -----> Create config file '/etc/awstats/awstats.hoge.com.conf' &br;  Config file /etc/awstats/awstats.hoge.com.conf created. &br;  &br; -----> Restart Web server with '/sbin/service httpd restart' &br; Redirecting to /bin/systemctl restart  httpd.service &br;  &br; -----> Add update process inside a scheduler &br; Sorry, configure.pl does not support automatic add to cron yet. &br; You can do it manually by adding the following command to your cron: &br; /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=hoge.com &br; Or if you have several config files and prefer having only one command: &br; /usr/local/awstats/tools/awstats_updateall.pl now &br; Press ENTER to continue... &br;  &color(lime){← 空ENTER}; &br;  &br; A SIMPLE config file has been created: /etc/awstats/awstats.hoge.com.conf &br; You should have a look inside to check and change manually main parameters. &br; You can then manually update your statistics for 'hoge.com' with command: &br; > perl awstats.pl -update -config=hoge.com &br; You can also read your statistics for 'hoge.com' with URL: &br; > http://localhost/awstats/awstats.pl?config=hoge.com &br;  &br; Press ENTER to finish... &br;  &color(lime){← 空ENTER};|
|[root@localhost awstats]# cd &color(lime){← ディレクトリ移動(ホームへ戻る)};|
|[root@localhost ~]# vi /etc/awstats/awstats.hoge.com.conf &color(lime){← 設定ファイル編集};|
|# "LogFile" contains the web, ftp or mail server log file to analyze. &br; # Possible values: A full path, or a relative path from awstats.pl directory. &br; # Example: "/var/log/apache/access.log" &br; # Example: "../logs/mycombinedlog.log" &br; # You can also use tags in this filename if you need a dynamic file name &br; # depending on date or time (Replacement is made by AWStats at the beginning &br; # of its execution). This is available tags : &br; #   %YYYY-n  is replaced with 4 digits year we were n hours ago &br; #   %YY-n    is replaced with 2 digits year we were n hours ago &br; #   %MM-n    is replaced with 2 digits month we were n hours ago &br; #   %MO-n    is replaced with 3 letters month we were n hours ago &br; #   %DD-n    is replaced with day we were n hours ago &br; #   %HH-n    is replaced with hour we were n hours ago &br; #   %NS-n    is replaced with number of seconds at 00:00 since 1970 &br; #   %WM-n    is replaced with the week number in month (1-5) &br; #   %Wm-n    is replaced with the week number in month (0-4) &br; #   %WY-n    is replaced with the week number in year (01-52) &br; #   %Wy-n    is replaced with the week number in year (00-51) &br; #   %DW-n    is replaced with the day number in week (1-7, 1=sunday) &br; #                              use n=24 if you need (1-7, 1=monday) &br; #   %Dw-n    is replaced with the day number in week (0-6, 0=sunday) &br; #                              use n=24 if you need (0-6, 0=monday) &br; #   Use 0 for n if you need current year, month, day, hour... &br; # Example: "/var/log/access_log.%YYYY-0%MM-0%DD-0.log" &br; # Example: "C:/WINNT/system32/LogFiles/W3SVC1/ex%YY-24%MM-24%DD-24.log" &br; # You can also use a pipe if log file come from a pipe : &br; # Example: "gzip -d </var/log/apache/access.log.gz &#124;" &br; # If there are several log files from load balancing servers : &br; # Example: "/pathtotools/logresolvemerge.pl *.log &#124;" &br; # &br; LogFile="/var/log/httpd/access_log" &color(lime){← Apacheアクセスログファイル名を指定}; &br;  &br; # Enter here all other possible domain names, addresses or virtual host &br; # aliases someone can use to access your site. Try to keep only the minimum &br; # number of possible names/addresses to have the best performances. &br; # You can repeat the "SiteDomain" value in this list. &br; # This parameter is used to analyze referer field in log file and to help &br; # AWStats to know if a referer URL is a local URL of same site or an URL of &br; # another site. &br; # Note: Use space between each value. &br; # Note: You can use regular expression values writing value with REGEX[value]. &br; # Note: You can also use @/mypath/myfile if list of aliases are in a file. &br; # Example: "www.myserver.com localhost 127.0.0.1 REGEX[mydomain\.(net &#124; org)$]" &br; # &br; HostAliases="127.0.0.1 localhost REGEX[^192\.168\.1\.]" &color(lime){← 自ホストおよび内部(例:192.168.1.x)からのアクセスをアクセス元(リファラ)から除外する}; &br;  &br; # Do not include access from clients that match following criteria. &br; # If your log file contains IP addresses in host field, you must enter here &br; # matching IP addresses criteria. &br; # If DNS lookup is already done in your log file, you must enter here hostname &br; # criteria, else enter ip address criteria. &br; # The opposite parameter of "SkipHosts" is "OnlyHosts". &br; # Note: Use space between each value. This parameter is not case sensitive. &br; # Note: You can use regular expression values writing value with REGEX[value]. &br; # Change : Effective for new updates only &br; # Example: "127.0.0.1 REGEX[^192\.168\.] REGEX[^10\.]" &br; # Example: "localhost REGEX[^.*\.localdomain$]" &br; # Default: "" &br; # &br; SkipHosts="127.0.0.1 localhost REGEX[^192\.168\.1\.]" &color(lime){← 自ホストおよび内部(例:192.168.1.x)からのアクセスをアクセス元(クライアント)から除外する}; &br;  &br; # If you want to have hosts reported by name instead of ip address, AWStats &br; # need to make reverse DNS lookups (if not already done in your log file). &br; # With DNSLookup to 0, all hosts will be reported by their IP addresses and &br; # not by the full hostname of visitors (except if names are already available &br; # in log file). &br; # If you want/need to set DNSLookup to 1, don't forget that this will reduce &br; # dramatically AWStats update process speed. Do not use on large web sites. &br; # Note: Reverse DNS lookup is done on IPv4 only (Enable ipv6 plugin for IPv6). &br; # Note: Result of DNS Lookup can be used to build the Country report. However &br; # it is highly recommanded to enable the plugin 'geoipfree' or 'geoip' to &br; # have an accurate Country report with no need of DNS Lookup. &br; # Possible values: &br; # 0 - No DNS Lookup &br; # 1 - DNS Lookup is fully enabled &br; # 2 - DNS Lookup is made only from static DNS cache file (if it exists) &br; # Default: 2 &br; # &br; DNSLookup=2 &br; &color(lime){↓}; &br; DNSLookup=1 &color(lime){← アクセス元の名前解決を行う(アクセス元をIPアドレスではなくホスト名で表示する)}; &br;  &br; # Plugin: GeoIPfree &br; # Perl modules required: Geo::IPfree version 0.2+ (from Graciliano M.P.) &br; # Country chart is built from an Internet IP-Country database. &br; # This plugin is useless for intranet only log files. &br; # Note: You must choose between using this plugin (need Perl Geo::IPfree &br; # module, database less up to date) or the GeoIP plugin (need Perl Geo::IP &br; # module from Maxmind, database more up to date). &br; # Note: Activestate provide a corrupted version of Geo::IPfree 0.2 Perl &br; # module, so install it from elsewhere (from www.cpan.org for example). &br; # This plugin reduces AWStats speed of 10% ! &br; # &br; #LoadPlugin="geoipfree" &br; &color(lime){↓}; &br; LoadPlugin="geoipfree" &color(lime){← コメント解除(アクセス元国情報を詳細に取得)}; &br;  &br; # When AWStats builds HTML links in its report pages, it starts those links &br; # with "http://". However some links might be HTTPS links, so you can enter &br; # here the root of all your HTTPS links. If all your site is a SSL web site, &br; # just enter "/". &br; # This parameter is not used if ShowLinksOnUrl is 0. &br; # Example: "/shopping" &br; # Example: "/" &br; # Default: "" &br; # &br; UseHTTPSLinkForUrl="/" &color(lightpink){← /を指定 ※[[''Web''サーバー間通信内容暗号化>Webサーバー間通信内容圧縮(mod_deflate)]]を導入している場合のみ};|
|[root@localhost ~]# yum -y install perl-CPAN &color(lime){← ''perl-CPAN''インストール};|
|[root@localhost ~]# perl -MCPAN -e shell &color(lime){← ''perl-CPAN''起動};|
|CPAN.pm requires configuration, but most of it can be done automatically. &br; If you answer 'no' below, you will enter an interactive dialog for each &br; configuration option instead. &br;  &br; Would you like to configure as much as possible automatically? [yes] &color(lime){← 空ENTER}; &br;  &br; Autoconfigured everything but 'urllist'. &br;  &br; Now you need to choose your CPAN mirror sites.  You can let me &br; pick mirrors for you, you can select them from a list or you &br; can enter them by hand. &br;  &br; Would you like me to automatically choose some CPAN mirror &br; sites for you? (This means connecting to the Internet) [yes] &color(lime){← 空ENTER}; &br; Trying to fetch a mirror list from the Internet &br; Fetching with LWP: &br; http://www.perl.org/CPAN/MIRRORED.BY &br;  &br; Looking for CPAN mirrors near you (please be patient) &br; .......................... done! &br;  &br; New urllist &br;   http://www.msg.com.mx/CPAN/ &br;   http://ftp.osuosl.org/pub/CPAN/ &br;   http://cpan.knowledgematters.net/ &br;  &br; Autoconfiguration complete. &br;  &br; commit: wrote '/root/.cpan/CPAN/MyConfig.pm' &br;  &br; You can re-run configuration any time with 'o conf init' in the CPAN shell &br; Terminal does not support AddHistory. &br;  &br; cpan shell -- CPAN exploration and modules installation (v1.9800) &br; Enter 'h' for help.|
|cpan[1]> install Geo::IPfree &color(lime){← ''Geo::IPfree''モジュールインストール};|
|cpan[2]> quit &color(lime){← ''perl-CPAN''終了};|
|Terminal does not support GetHistory. &br; Lockfile removed.|

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS