Enabling virtual hosting with lighttpd
From TekPedia
One must-have feature for a web server is virtual hosting, it enables the server to host multiple domains without them having to be under the same folder. Enabling and configuring this feature in lighttpd is pretty straightforward. Note: You still need to setup DNS entries for each of the domains.
First make sure that mod_simple_vhost is uncommented under the variable server.modules:
server.modules = ( "mod_simple_vhost", "mod_access", "mod_accesslog" )
Next edit the following lines with your own information:
simple-vhost.server-root = "/var/www/myexamplesites" simple-vhost.default-host = "example.com" simple-vhost.document-root = "/"
Edit: When lighttpd receives a request for a website (e.g. vhost1.com) it will check to see if directory simple-vhost.server-root + 'vhost1.com' + simple-vhost.document-root exists (i.e. /var/www/myexamplesites/vhost1.com/); if it does then the default page will be served, if the directory does not exist then the content from simple-vhost.default-host will be served.
To add more sites, simply create directories under simple-vhost.server-root:
/var/www/myexamplesites/example.com/ /var/www/myexamplesites/secondsite.com/ /var/www/myexamplesites/thirdsite.com/
and so on..
You can configure lighttpd settings for each virtual host by using $SERVER["host"] to match the domain.
