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