mod_lua on win32
mod_lua (what was mod_wombat, and is part of Apache core since version 2.3) is something which I'd quite like to work with for Google Summer of Code 2009. In order to work on it, you first need to be able to compile and run it. Doing this on linux is trivial - checkout the svn head of httpd, ./configure
(with appropriate command line arguments), make
and then sudo make install
. Doing so on Windows is less trivial, but it can be done.
For my Windows setup, I've got a standard binary distribution of win32 Apache 2.2.9 (complete with development include and library files) running on Vista. This makes things slightly more interesting, as mod_lua targets Apache 2.3 and above, but I can't find win32 binary distributions of 2.3, nor do I feel confident in compiling it under windows. From this baseline, I did the following:
- Checkout the mod_lua svn trunk (using TortoiseSVN)
- Create a new Visual Studio project and add all of the mod_lua source files
- Add additional include directories (
"E:\CPP\lua-5.1.4\src";"C:\Program Files\Apache Software Foundation\Apache2.2\include"
) - Add
LUA_DECLARE_EXPORT
to the preprocessor definitions - Add additional library directories (
"C:\Program Files\Apache Software Foundation\Apache2.2\lib";"E:\CPP\lua-5.1.4\Debug"
) - Add
lua5.1.lib
,libapr-1.lib
,libaprutil-1.lib
andlibhttpd.lib
to the library list - Add a post-build event to copy the resultant DLL to the modules folder (
cp "$(OutDir)\$(ProjectName).dll" "C:\Program Files\Apache Software Foundation\Apache2.2\modules\mod_lua.so"
) - Fix the usage of
AP_DECLARE
andAP_DECLARE_LUA
throughout the codebase (patch available on the httpd-dev mailing list) - Copy the
ap_args_to_table
andap_body_to_table
functions over from Apache 2.3'sutil_script.c
into a new file,util_script_ap23.c
. This is compilcated due toap_body_to_table
's usage of therequest_req::body_table
field, which is not present in the 2.2 version - but can be worked around via usage ofapr_pool_userdata_[sg]et
with the request's pool. - Compile the project and tweak
httpd.conf
as required to load and configure the module
(for comparison, similar info screenshot on the linux build)