以前、lighttpdでURLをrewriteというエントリーで、lighttpdのヴァーチャルホストの設定とURLのリライトルールに関して書いたけど、アクセスログとエラーログの設定が微妙に調べ切れなかったので、ちょっと調べてみた。
結局、設定名がエラーログと、アクセスログとで違う所が分かりにくくしている原因だった。
ここら辺に書いてあるんだけど、「accesslog.filename」をそのまま「error.filename」とかにするとエラーが出る。んで色々調べた結果「server.errorlog」という名前で設定すれば良かった。
以下に一応設定を書いておく、カスタムログの形式もここに書けるみたい。
$HTTP["host"] =~ "host\.example\.com" {
accesslog.format = "%h %l %u %t \"%r\" %b %>s \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-LIGHTTPD-SID}o\"",
server.document-root = "/path/to/document-root/",
server.errorlog = "/path/to/error.log",
accesslog.filename = "/path/to/access.log",
url.rewrite-once = (
"^/css/(.+)?$" => "$0",
"^/img/(.+)?$" => "$0",
"^/(.+)?$" => "/index.php/$1"
)
}というか、命名ルールをもうちょっと考えて欲しかったなぁ・・・。これバージョンアップとかで変わったりするとドヨーンとした気分になるぞ orz
URLの書き換えとかに利用するApacheの拡張であるmod_rewriteですが、Apacheの設定で「FollowSymLinks」設定がオフになっていると使えないようです。ただしmod_rewriteの設定を.htaccessから呼ぶ場合ね(ここ重要)。ちなみに、mod_rewriteのマニュアルは下記。
と、上のリンクのマニュアルを読み進めていくと以下のような文章が・・・。
The rewrite engine may be used in .htaccess files. To enable the rewrite engine for these files you need to set “RewriteEngine On” and “Options FollowSymLinks” must be enabled. If your administrator has disabled override of FollowSymLinks for a user’s directory, then you cannot use the rewrite engine. This restriction is required for security reasons.
あら、マニュアルにも書いてあるわいな。あっちゃー。ま、ざっくり言うと「Options -FollowSymLinks」ではダメで「Options FollowSymLinks」とかにしないとダメって事です。
私信になっちゃいますが、サーバーの対応してもらったMさん。本当にスイマセンm(_ _)m
elanbeat’s wiki経由。lighttpdを入れてログをlogrotateしてたんですが、ちゃんと再起動してくれないみたいで、困ったなと思ってた時に見つけた物。
ま、要するにpidを保存してあるファイルを指定してあげた方が良いでっせ。という事らしい。
/path/to/lighttpd/*log {
missingok
notifempty
sharedscripts
postrotate
/bin/kill -HUP `cat /path/to/lighttpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}上のようにlogrotate.dの中に置いてある設定ファイルを書く感じ。もちろんpidのファイルの場所と、ログの場所は変更する必要アリ。