Lighttpd with static modules

For the Nexus OS I need a version of lighttpd that is statically linked. Even when you build lighty as a static library, it by defaults expects to load its modules (access, dirlisting, staticfile, cgi, ...) at runtime. The following trick makes lightly include modules in the statically linked binary. It has been tested against version 1.4.25.


Compile with the debug flag -DLIGHTTPD_STATIC set. I noticed that my gcc (4.4.1) also
complained about syntax, so I had to force gcc to interpret as the C99 standard:


src/ changes

In src/ (from which configure generates src/Makefile), add the modules you want to include (say, mod_access and mod_staticfile) to all lists of input to target lighttpd. Specifically, add to am__liblightcomp_la_SOURCE_DIST, am__lighttpd_SOURCES_DIST and common_src:

mod_access.c mod_staticfile.c

And also add the objects.
To am__objects_1 and am__objects_2

mod_access.$(OBJEXT) mod_staticfile.$(OBJEXT)

As you see, I add the targets in total 5 times to the Makefile. That's probably
4 times unnecessarily, but it works. Add a comment if you have created
a shorter patch.

src/plugin.c changes

This file contains a line #include "plugin-static.h", but no such header is
generated. AFAIK this is a stale entry and no longer used. However, you can make lighty
aware of the statically linked modules by commenting out this line and adding these
immediately below it:



As always, leave a comment if you know an easier solution. If you want to see the
full patch, download the Nexus sources from the link at the top of this post. Note
that it includes additional modifications to handle the fact that Nexus is only
partially Posix complete.


  1. Thank you it's very helpful.
    And I found ordering of plugins is important.


Post a Comment