Project

General

Profile

[Solved] Making a very slim lighttpd server

Added by iselind about 6 years ago

I need a lighttpd server that is as slim as possible.

I currently build like so

tar xf lighttpd-1.4.48.tar.xz
cd lighttpd-1.4.48
./configure --without-bzip2 --with-openssl --disable-static --enable-shared --prefix=${PWD}/dist

From starting my server with the attached configuration it seems i only need
  • mod_alias.so
  • mod_cgi.so
  • mod_dirlisting.so
  • mod_indexfile.so
  • mod_openssl.so
  • mod_staticfile.so

in my lib folder. I cannot say why i need dirlisting, indexfile, and staticfile though. Is there a way to not require these three modules?

The build also produce the following so files

foo % ls | grep so
mod_accesslog.so*
mod_access.so*
mod_authn_file.so*
mod_auth.so*
mod_compress.so*
mod_deflate.so*
mod_evasive.so*
mod_evhost.so*
mod_expire.so*
mod_extforward.so*
mod_fastcgi.so*
mod_flv_streaming.so*
mod_proxy.so*
mod_redirect.so*
mod_rewrite.so*
mod_rrdtool.so*
mod_scgi.so*
mod_secdownload.so*
mod_setenv.so*
mod_simple_vhost.so*
mod_ssi.so*
mod_status.so*
mod_uploadprogress.so*
mod_userdir.so*
mod_usertrack.so*
mod_vhostdb.so*
mod_webdav.so*
mod_wstunnel.so*

I cannot find a way to not have these built. Any suggestions?

Is there something I can to do slim down the 1.3 MB main binary?

Any other suggestions you might have on how to create the slimmest possible lighttpd server given the attached configuration would be highly appreciated.

lighttpd.conf (798 Bytes) lighttpd.conf My lighttpd configuration

Replies (5)

RE: Making a very slim lighttpd server - Added by stbuehler about 6 years ago

The lighttpd binary in a debian package is about 250K; which means your build setup lacks certain basics. Start with optimization flags ("-O2", "-Os") and stripping binaries ("strip").

And just copy only the modules you need.

RE: Making a very slim lighttpd server - Added by iselind about 6 years ago

stbuehler wrote:

The lighttpd binary in a debian package is about 250K; which means your build setup lacks certain basics. Start with optimization flags ("-O2", "-Os") and stripping binaries ("strip").

The stripping i can do after the build, sure. How do i tell configure to include extra optimization flags?

And just copy only the modules you need.

That means i cannot use make install with --prefix=...

That's doable...

RE: Making a very slim lighttpd server - Added by stbuehler about 6 years ago

iselind wrote:

stbuehler wrote:

The lighttpd binary in a debian package is about 250K; which means your build setup lacks certain basics. Start with optimization flags ("-O2", "-Os") and stripping binaries ("strip").

The stripping i can do after the build, sure. How do i tell configure to include extra optimization flags?

The same way you'd do with any other standard autoconf-based source. ./configure -h shows various variables you can set. Although "-g -O2" might be default - watch the output of make.

RE: Making a very slim lighttpd server - Added by gstrauss about 6 years ago

You can build lighttpd statically if you have a desire to do so, but some modules, like openssl, might require more effort to do so.
https://redmine.lighttpd.net/boards/3/topics/5913
https://redmine.lighttpd.net/boards/3/topics/7591

Whether or not you build statically, if you do not want mod_indexfile, mod_dirlisting, or mod_staticfile to be built, then even though the modules are a required part of the build, you can modify the code in each module to be bare-bones and do nothing, e.g. for mod_staticfile

#include "first.h" 

#include "buffer.h" 
#include "plugin.h" 

typedef struct plugin_data {                                                                    
    PLUGIN_DATA;                                                                                
} plugin_data;                                                                                  

INIT_FUNC(mod_staticfile_init) {                                                                
    return calloc(1, sizeof(struct plugin_data));                                           
}                                                                                               

FREE_FUNC(mod_staticfile_free) {
    UNUSED(srv);
    UNUSED(p_d);
    return HANDLER_GO_ON;
}

SETDEFAULTS_FUNC(mod_staticfile_set_defaults) {
    UNUSED(srv);
    UNUSED(p_d);
    return HANDLER_GO_ON;
}

int mod_staticfile_plugin_init(plugin *p);
int mod_staticfile_plugin_init(plugin *p) {
    p->version     = LIGHTTPD_VERSION_ID;
    p->name        = buffer_init_string("staticfile");

    p->init        = mod_staticfile_init;
    p->set_defaults= mod_staticfile_set_defaults;
    p->cleanup     = mod_staticfile_free;

    p->data        = NULL;

    return 0;
}

RE: [Solved] Making a very slim lighttpd server - Added by gstrauss about 6 years ago

If you want "better control of which modules get built", and you are using autotools build (the default), then modify Makefile.am to delete what you do not want.

If your next response is "show me how to do this" and you are unable to take these hints and go learn something before asking further targetted questions, then everything above isn't for you.

    (1-5/5)