【サブPC 自宅サーバ化計画 CentOS7版】Webサーバーのログビューワー AWStat の導入

1.AWStatのファイルを取得し、Webサーバー内フォルダにコピーして展開

$ wget https://prdownloads.sourceforge.net/awstats/awstats-7.6.tar.gz
$ cp -p awstats-7.6.tar.gz /path/to/
$ cd /path/to
$ tar xvf awstats-7.6.tar.gz

2.セットアップ用の設定ファイルを編集する

$ cd /path/to/awstats-7.6/tools
$ sudo vi httpd_conf
(略)
# "/usr/local/awstats/"と記述されている箇所を、実際のAWStatの展開先に書き換えること
# 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 "/path/to/awstats-7.6/wwwroot/classes/"
Alias /awstatscss "/path/to/awstats-7.6/wwwroot/css/"
Alias /awstatsicons "/path/to/awstats-7.6/wwwroot/icon/"
ScriptAlias /awstats/ "/path/to/awstats-7.6/wwwroot/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/path/to/awstats-7.6/wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
$ sudo perl awstats_configure.pl

3.設定用スクリプトを叩く

$ cd /path/to/awstats-7.6/tools
$ sudo perl awstats_configure.pl
----- AWStats awstats_configure 1.0 (build 20140126) (c) Laurent Destailleur -----
(略)
-----> 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:
/exData/iwakiri/public_html/awstats-7.6
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を叩く

-----> Check for web server install
(略)
Config file path ('none' to skip web server setup):
>
/etc/httpd/conf/httpd.conf ← Apacheのコンフィグファイルを指定

-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
(略)
-----> 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を叩く

-----> 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:
>
local-server ← プロファイルの名前を記入。あくまでもAWStat上での表示用

-----> 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.local-server.conf'
Config file
/etc/awstats/awstats.local-server.conf created. → これが設定ファイルなので控えておく

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

/exData/iwakiri/public_html/awstats-7.6/wwwroot/cgi-bin/awstats.pl -update -config=local-server → これが情報の更新用スクリプトなので控えておく
Or if you have several config files and prefer having only one command:
/exData/iwakiri/public_html/awstats-7.6/tools/awstats_updateall.pl now

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

You can also read your statistics for 'local-server' with URL:
>
http://localhost/awstats/awstats.pl?config=local-server →これがAWStatのURLとなるが、localhostの部分は実際のWebサーバーのIP or URLに置き換える

Press ENTER to finish...

4.サイトごとの設定ファイルを編集し、情報更新のスクリプトを叩く

$ sudo vi /etc/awstats/awstats.local-server.conf
*下記の2箇所を修正

#LogFile="/var/log/httpd/mylog.log"
LogFile="/var/log/httpd/access_log"

#DirData="/var/lib/awstats"
DirData="." → awstats.plと同じディレクトリを指定

$ sudo perl awstats.pl -update -config=local-server

これで、ブラウザから http://(WebサーバーのIP or URL)/awstats/awstats.pl?config=local-server にアクセスしてAWStatの画面が表示されればOK。

 

コメント

タイトルとURLをコピーしました