3

I want to use lighttpd as a development server, similar to WEBrick for Rails, or manage.py runserver for Django. (This is for both PHP and for learning Javascript where I can't use AJAX on the local filesystem). I also want to be able to share the result with other developers through checking in the conf file to source control along with the code, so I want paths relative to the conf file, not absolute paths that are only valid on my system.

So I saw this answer about using lighttpd which is very close to what I want. However, rather than having to change to the correct directory and then run the script, ideally I want to be able to do:

lighttpd -f path/to/lighttpd.conf

and for the document root to be relative to the directory the lighttpd.conf file is in. So I want to be able to have a config line something like:

server.document-root = dirname(__file__) + "/html"

The answer linked to above uses CWD for the directory, so this seems like something that might well be available. Any idea how to specify it?

(As a side note, can anyone link to a comprehensive reference to lighttpd.conf and the options available? I haven't been able to find one.)

Community
  • 1
  • 1
Hamish Downer
  • 16,603
  • 16
  • 90
  • 84
  • 1
    About the configuration, every thing is on the [official documentation](http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions). I didn't find anything better atm. – j0k Jul 28 '12 at 17:09

2 Answers2

3

That is not possible - you should (as you already know)

cd /some/testing/dir/with/your/stuff
lighttpd -f lighttpd.conf

plus the var.CWD in your directory

server.document-root = var.CWD

An alternative would be to patch lighttpd yourself with an option that supplies an additional pseudo-chroot argument.

drahnr
  • 6,782
  • 5
  • 48
  • 75
0

You can call envsubst on your config, setting up $PWD or some other variable

envsubst < lighttpd.conf.template > lighttpd.conf

iggy
  • 1,613
  • 1
  • 18
  • 35