ModAuth Documentation

Rather than using htpasswd from an Apache install, there is an online htpasswd generator which can be used to create the htpasswd file.

Add mod_auth to /service/lighttpd/root/lighttpd.conf:


Stop image bandwidth theft

Prevent other websites from stealing your bandwidth by including your images in their pages.

  • Apache
    This example services up a different image instead:

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} ^http://.*$
    RewriteRule \.(jpe?g|gif|bmp|png)$ /media/nohotlinks.png [L]
  • Lighttpd
    $HTTP["referer"] !~ "^(http://example\.com|http://www\.example\.com)" {
      $HTTP["referer"] != "" {
        url.access-deny = ( ".jpg", ".jpeg", ".png", ".gif", ".pdf" )


spawn-fcgi allows you to run FastCGI separate from Lighttpd.

cd /extra/src
tar zxf spawn-fcgi-1.6.3
cd spawn-fcgi-1.6.3

Automatic Startup
FastCGI can be supervised by daemontools.
Assuming you have already installed daemontools, create the directories to hold the lighttpd run script, logging script, and config files:

cd /var/service
mkdir -m 1755 fast-cgi
cd fast-cgi

Create the run script (/var/service/fast-cgi/run), with the following:



Compress output from your web server to save on bandwidth and improve throughput.

Add mod_compress to server.modules directive of /service/lighttpd/root/lighttpd.conf:

server.modules += ( "mod_compress" )

Add a compress.cache-dir directive for where compressed files will be stored. This directive can also go in an $HTTP host directive if you want different cache directories per virtual host:

compress.cache-dir = "/tmp/lighttpdcompress/"

Define which mimetypes will be compressed. This example will compress Javascript, plain text, css, and XML files:



XCache is a open-source opcode cacher, which means that it accelerates the performance of PHP on servers. It optimizes performance by removing the compilation time of PHP scripts by caching the compiled state of PHP scripts into the shm (RAM) and uses the compiled version straight from the RAM. This will increase the rate of page generation time by up to 5 times as it also optimizes many other aspects of php scripts and reduce server load.

If phpize complains about being unable to find autoconf:

yum install autoconf

Installation with Lighttpd
Download the latest release of Xcache:

cd /extra/src
tar zxf xcache-1.3.2.tar.gz
cd xcache-1.3.2
./configure --enable-xcache
make install

Copy the default configuration into your php.ini:


Virtual Hosts

Create a directory to hold the virtual host config files:

cd /var/service/lighttpd/root
mkdir sites

Create a conf file for your virtual host, /var/service/lighttpd/root/sites/

var.basedir = "/var/websites/"
server.document-root = basedir + "htdocs/
accesslog.filename = basedir + "logs/access.log"

Edit /var/service/lighttpd/root/lighttpd.conf and add:

# map all domains of a top-level-domain to a single document-root
$HTTP["host"] =~ "(^|\.)example\.com$" {


SquirrelMail with Lighttpd


Lighttpd Configuration

Edit your lighttpd.conf and add an alias for your Squirrelmail install:

alias.url = (
"/webmail" => "/var/websites/webmail/squirrelmail",

Qmailadmin with Lighttpd

Configure Qmailadmin to work with the Lighttpd webserver.

Lighttpd Configuration
With a basic Lighttpd server configured as per this site's instructions and running under daemontools, create a file /service/lighttpd/root/ to hold the server options for Qmailadmin:

alias.url = (
"/cgi-bin/qmailadmin" => "/var/websites/mail/cgi-bin/qmailadmin",
"/images/qmailadmin" => "/var/websites/mail/htdocs/images/qmailadmin"

$HTTP["url"] =~ "^/cgi-bin/qmailadmin" {
cgi.assign = ( "/var/websites/mail/cgi-bin/qmailadmin" => "" )



Subscribe to RSS - lighttpd

Recent Updates

  • 2 years 1 month ago
  • 2 years 1 month ago
  • 2 years 1 month ago
    php 8.x
  • 2 years 1 month ago
  • 2 years 1 month ago
    Drop Centos 5/6 stuff