lighttpd

Authentication

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:

Technology:

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

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

cd /extra/src
wget http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.gz
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:

Technology:

mod_compress

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:

Technology:

Xcache

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.

Requirements
If phpize complains about being unable to find autoconf:

yum install autoconf

Installation with Lighttpd
Download the latest release of Xcache:

cd /extra/src
wget http://xcache.lighttpd.net/pub/Releases/1.3.2/xcache-1.3.2.tar.gz
tar zxf xcache-1.3.2.tar.gz
cd xcache-1.3.2
phpize
./configure --enable-xcache
make
make install

Copy the default configuration into your php.ini:

Technology:

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/www.example.com.conf:

var.basedir = "/var/websites/www.example.com/"
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$" {

Technology:

SquirrelMail with Lighttpd

Prerequisites

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/qmailadmin.inc 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" => "" )
}

Technology:

Pages

Subscribe to RSS - lighttpd

Recent Updates

  • 1 month 23 hours ago
    1.27.2 update
  • 1 month 1 week ago
    Drupal 10/11 config
  • 1 month 1 week ago
  • PHP
    1 month 1 week ago
    PHP 8.3.11 and AlmaLinux
  • 1 month 2 weeks ago
    New version of Pound