Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 94 lines (72 sloc) 2.66 kb
018940c Tzury Bar Yochay edit
tzuryby authored
1 ---
2 layout: default
3 title: Webpy + LightTTPD with FastCGi
4 ---
5
6 # Webpy + LightTTPD with FastCGi
7
8 The following applies to lighttpd version 1.4.18
9
5849fae Tzury Bar Yochay edit
tzuryby authored
10 If you are not certain what version yo uare running simply type: <code>lighttpd -v</code> at your console.
7552bed Tzury Bar Yochay edit
tzuryby authored
11
9a47e9f Tzury Bar Yochay edit
tzuryby authored
12 Note: Earlier version of lighttpd may organize the .conf files differently. Yet, the same principles applied to them as well.
5849fae Tzury Bar Yochay edit
tzuryby authored
13
14 ###ligghttpd Configuration under Debian GNU/Linux
7552bed Tzury Bar Yochay edit
tzuryby authored
15
16 <pre>
17 Files and Directories in /etc/lighttpd:
18 ---------------------------------------
19
20 lighttpd.conf:
21 main configuration file
22
23 conf-available/
24 This directory contains a series of .conf files. These files contain
25 configuration directives necessary to load and run webserver modules.
26 If you want to create your own files they names should be
27 build as nn-name.conf where "nn" is two digit number (number
28 is used to find order for loading files)
29
30 conf-enabled/
31 To actually enable a module for lighttpd, it is necessary to create a
32 symlink in this directory to the .conf file in conf-available/.
33
34 Enabling and disabling modules could be done by provided
35 /usr/sbin/lighty-enable-mod and /usr/sbin/lighty-disable-mod scripts.
8659d5e Tzury Bar Yochay edit
tzuryby authored
36 </pre>
018940c Tzury Bar Yochay edit
tzuryby authored
37
7d445cf Tzury Bar Yochay edit
tzuryby authored
38 <strong>
899b3f5 Tzury Bar Yochay edit
tzuryby authored
39 For web py you should enable mod_fastcgi and mod_rewrite, thus run: <code>/usr/sbin/lighty-enable-mod</code> and supply <code>fastcgi</code>
40 (mode_rewrite will be enabled within <code>10-fastcgi.conf</code> file as you will see in a moment).
7d445cf Tzury Bar Yochay edit
tzuryby authored
41
3488a59 Tzury Bar Yochay edit
tzuryby authored
42 Below are instructions for the following files:
43 * /etc/lighttpd/lighttpd.conf
44 * /etc/lighttpd/conf-available/10-fastcgi.conf
45 * code.py
018940c Tzury Bar Yochay edit
tzuryby authored
46
47 <code>/etc/lighttpd/lighttpd.conf</code>
48
49 <pre>
50 server.modules = (
51 "mod_access",
52 "mod_alias",
53 "mod_accesslog",
54 "mod_compress",
55 )
56 server.document-root = "/path/to/webpy/app/root-dir"
57 </pre>
58
59 In my case I used postgresql and therefore runs lighttpd as postgres in order to grant permissions to the database, therefore I added the line:
60
61 <pre>
62 server.username = "postgres"
63 </pre>
64
65 <code>conf-enabled/10-fastcgi.conf</code>
66
3671502 Tzury Bar Yochay edit
tzuryby authored
67 <pre>
6f3f158 Tzury Bar Yochay edit
tzuryby authored
68 server.modules += ( "mod_fastcgi" )
69 server.modules += ( "mod_rewrite" )
018940c Tzury Bar Yochay edit
tzuryby authored
70
71 fastcgi.server = ( "/code.py" =>
72 (( "socket" => "/tmp/fastcgi.socket",
73 "bin-path" => "/path/to/code.py",
74 "max-procs" => 1,
75 "bin-environment" => (
76 "REAL_SCRIPT_NAME" => ""
77 ),
78 "check-local" => "disable"
79 ))
80 )
81
82 url.rewrite-once = (
83 "^/favicon.ico$" => "/static/favicon.ico",
84 "^/static/(.*)$" => "/static/$1",
85 "^/(.*)$" => "/code.py/$1",
86 )
87 </pre>
88
89 <code>/code.py</code>
90 at the top of the file add:
91
92 <pre>
93 #!/usr/bin/env python
94 </pre>
Something went wrong with that request. Please try again.