Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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