Project

General

Profile

LighttpdUnderSuperviseExampleConfiguration » History » Revision 4

Revision 3 (conny, 2006-01-30 14:54) → Revision 4/5 (stbuehler, 2009-03-28 14:48)

h1. Lighttpd configuration layout 

 

 The application configuration files can be placed below the service directory as well in a _djbdns_-similar way. Thanks to the include-directives of Lighttpd, your configuration can be split up into smaller parts, put into subdirectories, and maybe even _shared_ between multiple lighttpd service instances.  

 Similarly, by combining the environment variable substitution directives ("env.*") with the envdir program your configuration could be modularized almost _ad infinitum_. 

 The term "service instance" is used to refer to the fact that it works perfectly well to have multiple instances of lighttpd running on your server, each on different ip/ports with different privileges. 

 



 h2. Example 1 

 

 Continuing on the example used in LighttpdUnderSupervise: 

 

 <pre> 
 

 /srv/lighttpd-main/ 
 /srv/lighttpd-main/root/           # root directory of the lighttpd configuration 
 /srv/lighttpd-main/root/common/ -> /etc/lighttpd/common/ # symlink pointing to a shared directory 
 /srv/lighttpd-main/root/htdocs/    # default website root 
 /srv/lighttpd-main/root/sites/     # vhost configuration files 
 </pre> 

 



 h3. File ./run 

 


 <pre> 
 

 #! /bin/sh 

 exec 2>&1 
 exec softlimit -m 700000000 /usr/sbin/lighttpd -D -f ./root/lighttpd.conf 
 </pre> 

 



 h3. File ./root/lighttpd.conf 

 

 Because we used the -f parameter, the base for other included files will be /srv/lighttpd-main/root/. 

 

 <pre> 
 

 include "modules.inc" 
 include "common/common.inc" 

 # default site 
 server.bind         = "192.168.8.160" 
 include "sites/default" 

 # "Multiple bind" hack 
 $SERVER["socket"] == "132.12.21.20:80" { 
         include "sites/foo.com" 
 } 
 $SERVER["socket"] == "132.12.21.21:80" { 
         include "sites/foo.co.jp" 
 } 
 $SERVER["socket"] == "132.12.21.22:80" { 
         include "sites/foo.se" 
 } 
 </pre> 

 



 h3. File ./root/modules.conf 

 


 <pre> 
 

 server.modules = ( 
                    "mod_rewrite", 
                    "mod_alias", 
 ... 
 </pre> 

 



 h3. File ./root/common/common.inc 

 


 <pre> 
 

 server.pid-file = "./supervise/lighttpd.pid"    # server.pid-file ...or maybe ./root/lighttpd.pid is not needed  
 "cleaner" 
 server.username    = "www-data" 
 #server.max-keep-alive-idle = 30 
 ... 
 </pre> 

 



 h3. File ./root/sites/default 

 


 <pre> 
 

 server.document-root = "./root/htdocs/" # default website root 
 status.status-url = "/server-status" 
 ... 
 </pre> 

 



 h3. File ./root/sites/foo.com 

 


 <pre> 
 

 # No $HTTP["host"] match required in this example since this site  
 # file was included from within a $SERVER["socket"] stanza... 
 server.document-root = /home/foo.com/wwwroot/ 
 ... 
 </pre>