Here examples how to use PyLucid with lighttpd.

install lighttpd

1
2
3
4
5
~$ sudo aptitude install lighttpd
~$ cd /etc/lighttpd/
/etc/lighttpd# mv lighttpd.conf lighttpd.conf.bak
/etc/lighttpd# touch lighttpd.conf
/etc/lighttpd# nano lighttpd.conf

lighttpd.conf

Example for a /etc/lighttpd/lighttpd.conf:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
server.modules = (
	"mod_access",
	"mod_alias",
	"mod_compress",
        "mod_rewrite",
        "mod_fastcgi",
)

server.document-root        = "/var/www"
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"

index-file.names            = ( "index.html", "index.htm" )

url.access-deny             = ( "~", ".inc", ".db" )

static-file.exclude-extensions = ( ".fcgi", )

## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl"

## http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModDirlisting
#server.dir-listing  = "enable"
server.dir-listing   = "disable"
dir-listing.encoding = "utf-8"

## http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModCompress
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype  = (
    "application/javascript",
    "application/x-javascript",
    "text/css", "text/html", "text/plain"
)

include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"


## Example for setup "Site1":
$HTTP["host"] == "www.YourSite1.tld" {
    server.document-root = "/var/www/YourSite1"

    # http://redmine.lighttpd.net/wiki/lighttpd/Docs%3AModFastCGI
    fastcgi.server = (
        "/index.fcgi" => (
            "main" => (
                "socket" => "/tmp/site1_fastcgi_server.sock",
                "bin-path" => "/var/www/YourSite1/index.fcgi",
                "check-local" => "disable",
                
                ## the number of fastcgi processes that will be started (default is 4):
                #"max-procs" => 1,
            )
        ),
    )

    alias.url = (
        "/media" => "/var/www/YourSite1/static/",
    )

    url.rewrite-once = (
        "^(/media.*)$" => "$1",

        "^/favicon\.ico$" => "/favicon.ico",
        #"^/favicon\.ico$" => "/static/favicon.ico",

        "^(/.*)$" => "/index.fcgi$1",
    )
}

## Partial example for setup "Site2":
$HTTP["host"] == "www.site2.tld" {
    server.document-root = "/var/www/YourSite2"
    fastcgi.server = (
       ...
    )
    ...
}

local_settings.py

Importend is that you add FORCE_SCRIPT_NAME into your local_settings.py:

1
FORCE_SCRIPT_NAME = ""

See also: https://code.djangoproject.com/ticket/11694

control lighttpd

To restart lighttpd run this:

1
sudo /etc/init.d/lighttpd restart

links