Search code examples
lighttpd

lighttpd: symlink as document root


Is it possible to use a symlink as document root for lighttpd?

I tried it with:

ln -s ./www-1 ./doc-root

And then:

server.document-root = var.CWD + "/doc-root"

But it appears that lighttpd just resolves the symlink and uses that as document root instead.

Essentially I want to switch between two document roots without patching the current config, restarting or spawning another instance of lighttpd.

Sadly mod_alias shows the same behavior:

alias.url = ( "/" => var.CWD + "/doc-root" )


Solution

  • Yes, lighttpd supports symlinks.

    You are messing yourself up by using var.CWD, which uses getcwd() to determine the current working directory. This resolution of the current working directory resoves symlinks when determining the current working directory.

    Use var.mysymlinkroot instead of var.CWD, and define var.mysymlinkroot to be the path to the symlink.