Apacheのログを各ユーザーごとに取得する |
# mkdir /var/log/httpd/ユーザー名 ← ユーザー個別のログディレクトリ作製 /etc/httpd/conf/httpd.confの編集 /~ユーザー名 の場合下記を追記 SetEnvIf Request_URI "/~ユーザー名/" ユーザー名 nolog CustomLog /var/log/httpd/ユーザー名/access_log combined env=ユーザー名 バーチャルドメインの場合 <VirtualHost*> ServerAdmin ユーザー名@aaa.net DocumentRoot /home/ユーザー名/public_html ServerName zzzz.xxxx.ne.jp ErrorLog /var/log/httpd/ユーザー名/error_log ← ログを個別に取るように追記 CustomLog /var/log/httpd/ユーザー名/access_log combined env=!nolog ← ログを個別に取るように追記 </VirtualHost> |
ログローテーションの設定 |
一定期間たまったログを古い物から削除する設定です。
# vi /etc/logrotate.d/apache Apacheのメインログ設定 /var/log/httpd/access_log { daily ← 好みでdaily, weekly, monthlyのいずれかを指定 rotate 14 ← ここで履歴の数を指定 missingok postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true endscript } 上記のように、/etc/logrotate.confへローテートのスケジュールと 履歴回数を指定しておけば、一定期間で古いログは削除されるようになります。 ユーザーのログ設定 /var/log/httpd/*/access_log { daily ←毎日という意味 rotate 14 ←14日間という事 missingok postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true endscript } /var/log/httpd/*/error_log { daily rotate 14 missingok postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true endscript } 設定できたら保存 |
Copyright c Vine Linuxで自宅サーバー. 2004 All Rights Reserved.