KfWiki : Lighttpd

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
HomePage » WebServer » Lighttpd


Lighttpd

lighttpd seems to be picking up momentum as a high performance alternative to apache.

Installation
Configure options:
./configure --prefix=/usr --sysconfdir=/etc/lighttpd --disable-ipv6 --with-openssl=/usr


Configuration
One can use the sample config under lighttpd-src/docs/lighttpd.conf and make modifications.

SSL
Check that lighttpd has ssl support
> lighttpd -v
lighttpd-1.4.13 (ssl) - a light and fast webserver


Then add these to lighttpd.conf. No need to add 443 to server.port
$SERVER["socket"] == "206.188.19.110:443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/ssl/web.adblade.com.pem"
ssl.ca-file = "/etc/lighttpd/ssl/gd_bundle.crt"
server.name = "web.adblade.com"
server.document-root = "/home/admin/httpdocs"
}


Starting
lighttpd -f /etc/lighttpd/lighttpd.conf


php
lighttpd.conf
fastcgi.server = ( ".php" =>
    ( "localhost" =>
        (
            "socket" => "/tmp/php-fastcgi.socket",
            "bin-path" => "/usr/local/php-fcgi/bin/php"
        )
    )
)


php (lighttpd 1.5+)
Run a fastcgi background process, and use mod_proxy to connect to it.
 /usr/bin/spawn-fcgi -s /tmp/php-fastcgi.sock -f /usr/bin/php-cgi -uwww -g www -C 5 -P /var/run/spawn-fcgi.pid


lighttpd.conf
server.modules += ( "mod_proxy_backend_fastcgi" )
$HTTP["url"] =~ "\.php$" {
       proxy-core.balancer = "round-robin"
       proxy-core.allow-x-sendfile = "enable"
#       proxy-core.check-local = "enable"
       proxy-core.protocol = "fastcgi"
       proxy-core.backends = ( "unix:/tmp/php-fastcgi.sock" )
       proxy-core.max-pool-size = 16
}



Tomcat (lighttpd 1.5+)
lighttpd.conf
server.modules  += ( "mod_proxy_core",  "mod_proxy_backend_ajp13" )
$HTTP["url"] =~ "^/tomcat/" {
  proxy-core.balancer = "round-robin"
  proxy-core.protocol = "ajp13"
  proxy-core.backends = ( "localhost:8009" )
  proxy-core.max-pool-size = 16
}


Redirect
   $HTTP["url"] !~ "^/admin" {
		url.redirect = ( "(.*)" => "www.mentalhelp.net$1" )
   }


		   $HTTP["querystring"] == "page=home" {
				$HTTP["url"] =~ "^/home.html" {
						url.redirect = ( "^/(.*)" => "/index.html" )
				}
		   }


simple vhost
$HTTP["host"] =~ "domain1\.com" {
			server.document-root = "/home/lighttpd/domain1.com/http"
			accesslog.filename         = "/home/lighttpd/domain1.com/logs/access.log"
}


evhost vhost
evhost is a very powerful vhost configuration tool. if one doesn't wrap the evhost directive around with a socket match, it will serve request for 0.0.0.0:*. Not a problem if all the sites are ran on the same IP and no SSL sites are served. Otherwise, the following example uses evhosts in conjunction with simple vhost to serve plain and secure sites:

$SERVER["socket"] == "0.0.0.0:80" { 
	evhost.path-pattern        = "/home/sites/www.%0/web/"
}

$SERVER["socket"] == "1.2.3.4:443" { 
	ssl.engine                  = "enable" 
	ssl.pemfile                 = "/home/sites/www.domain.tld.pem" 
	server.document-root        = "/home/sites/www.domain.tld/web" 
}


evhost variable:
%0 => domain name + tld
%1 => tld
%2 => domain name without tld
%3 => subdomain 1 name
%4 => subdomain 2 name

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.7347 seconds