# アクセスログ解析AWStatsの導入

**URL:** https://forum.ficusonline.com/t/awstats/27
**Category:** Server
**Created:** [2016 年 10 月 6 日午後 11:07 UTC](https://forum.ficusonline.com/t/awstats/27 "2016-10-06T23:07:27Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2019 年 5 月 27 日午後 1:02 UTC](https://forum.ficusonline.com/t/awstats/27/4 "2019-05-27T13:02:52Z")

</div>

**3. Crontabの設定**

www-dataにApacheログファイルの読み取り権限を付与しても、新規ログファイルが作成されると無効になり統計データに反映されません。

> **[Bug #1252467 “/etc/cron.d/awstats: wrong user for cron job” : Bugs : awstats...](https://bugs.launchpad.net/ubuntu/+source/awstats/+bug/1252467)**
>
> /etc/cron.d/awstats runs the statistics generation cron job with user "www-data". The cron job needs to access /var/log/apache2/access.log.
> 
> $ ls -al /var/log/apache2/access.log
> \-rw-r----- 1 root adm 342337 Nov 18 21:36 /var/log/apache2/access.log
> 
> $...

**awstats** という新規ユーザを作成し、このユーザをwww-data,admグループに追加します。

> $ sudo useradd awstats  
> $ sudo usermod -a -G www-data awstats  
> $ sudo usermod -a -G adm awstats

awstatsのクローンジョブユーザ名を変更します。

> $ sudo pico /etc/cron.d/awstats

```auto
#MAILTO=root

*/10 * * * * awstats [-x /usr/share/awstats/tools/update.sh] && /usr/share/awstats/tools/update.sh

# Generate static reports:
#10 03 * * * awstats [-x /usr/share/awstats/tools/buildstatic.sh] && /usr/share/awstats/tools/buil$

```

以下フォルダ内の所有権をユーザawstatsに変更します。

> $ sudo chown -R awstats:www-data /var/lib/awstats

以下スクリプトをユーザawstatsで実行します。エラーが表示されなければ統計データのアップデートは無事完了です。ブラウザで表示を確認して下さい。

> $ sudo -u awstats /usr/share/awstats/tools/update.sh

**ブラウザで任意の時間にアップデートする場合**

以下の変更でブラウザ表示画面上部にアップデートリンクが作成されます。

> $ sudo pico /etc/awstats/awstats.ficus.myvnc.com.conf

```auto
AllowToUpdateStatsFromBrowser=1

```

---

_[View the full topic](https://forum.ficusonline.com/t/awstats/27)._
