Are you attracted by lighttpd 1.4.12's new mod_magnet?
mod_magnet is a solution to the long-standing quandary of complex URL rewriting without Apache's mod_rewrite. Don't be confused by lighttpd's mod_rewrite; that module should really be called mod_url_find_and_replace.
The gotcha: mod_magnet requires Lua, an embedded programming language created in Brazil. This is the same language that lighttpd's mod_cml uses for Cache Meta Language.
I tried installing Lua via DarwinPorts, but it didn't work. Lighttpd would just complain if I tried enabling mod_magnet:
% /usr/local/sbin/lighttpd -f ~/etc/lighttpd.conf -D
2006-09-24 22:18:05: (plugin.c.213) mod_magnet plugin init failed
2006-09-24 22:18:05: (server.c.577) loading plugins finally failed
After much tinkering, here's how I got mod_magnet working.
Build pkgconfig
Get & unarchive pkgconfig (currently 0.21) from:
http://pkgconfig.freedesktop.org/releases/
% cd pkg-config-0.21
% ./configure
% make
% sudo make install
Build LUA
Get & unarchive Lua (currently 5.1.1) from:
http://www.lua.org/ftp/
% cd lua-5.1.1/
% make macosx
% sudo make install
% sudo cp etc/lua.pc /usr/local/lib/pkgconfig/
% sudo ranlib /usr/local/lib/liblua.a
Build lighttpd
Get & unarchive lighttpd (currently 1.4.12) from:
http://www.lighttpd.net/download/
% cd lighttpd-1.4.12/
% ./configure --with-lua
% make
% sudo make install
Configure mod_magnet
Now lighttpd should be happy to hook you up with the magnet! Enable mod_magnet in your lighttpd.conf and specify a magnet file in the context that you need it.
server.modules = ( .. "mod_magnet" .. )
magnet.attract-physical-path-to = ("/path/to/url_rewriting_magnet.lua")
See the mod_magnet docs for the official word.
Next Time... LuaFileSystem on OS X
In my next geekerific article, we'll install LuaFileSystem on OS X for filesystem-aware URL rewriting with lighttpd.
3 Responses to “mod_magnet on OS X”
Leave a Reply