Apache より速いという噂の Lighttpd でプラグインを書くには
とりあえずスケルトンコードをいじる。
手始めにそのスケルトンコードを動かしてみるのまとめ。
Lighty Writing Plugin
http://redmine.lighttpd.net/wiki/lighttpd/HowToWriteALighttpdPlugin
↑のまとめ。
必要なツール
- automake 1.8 以上
- autoconf 2.57 以上
- libtool 1.5 以上
- srcフォルダの mod_skeleton.c を mod_counter.c などと書き換える。
- mod_counter.c を開き skelton を counter などと全て置換する。
- srcフォルダの Makefile.am に以下を追記する。
lib_LTLIBRARIES += mod_counter.la mod_counter_la_SOURCES = mod_counter.c mod_counter_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined mod_counter_la_LIBADD = $(common_libadd)
- lighttpd-1.5.0(または1.4)のディレクトリで
./configure –enable-maintainer-mode
をして Makefile を再作成する。 - make を実行しても src ディレクトリに mod_counter.la やら mod_counter.lo ができないときは
autoreconf -fi
をしてから再度
./configure –enable-maintainer-mode
を実行する。
もしもconfigure.in:19: error: possibly undefined macro: AC_DISABLE_STATIC configure.in:20: error: possibly undefined macro: AC_PROG_LIBTOOL
などとエラーが大量に出たら libtool がシステムに入っていないので libtool を頑張ってインストールする。
- おもむろに make、sudo make install
- lighttpd.conf に追加するプラグインを指定する。
server.modules = ( …… "mod_counter" )
- さらにプラグインの設定を追加する。
counter.array = (".html")
- Lighty 起動して上で設定した拡張子のファイルにアクセスしてみる。
mod_counter が動いているなら 403 が返ってくるはず。 - なぜ 403 が返ってくるかはソース。