1 Configuring Apache
2 ==================
3
4 To configure applications without authenticators, use the config.py script
5 in tools/Apache to set up CGI applications. For example:
6
7 python tools/Apache/config.py \
8 CGI \
9 /home/paulb/Software/Python/WebStack/examples/CGI/CookiesApp.py \
10 /etc/apache2/sites-available \
11 cookies \
12 /cgi/cookies
13
14 This script can also be used to configure mod_python applications. Run the
15 script without any arguments to see the documentation.
16
17 With the above command, the "cookies" application should be visitable with a
18 URL resembling this one:
19
20 http://localhost/cgi/cookies
21
22 The Manual Way
23 --------------
24
25 Declare the script in httpd.conf or equivalent Web server configuration file.
26 For example:
27
28 ScriptAlias /cgi/simple "/home/paulb/Software/Python/WebStack/examples/CGI/SimpleHandler.py"
29
30 The WebStack package must reside on the PYTHONPATH, along with the package
31 containing the application itself. Therefore, ensure that the handler uses the
32 appropriate entries in sys.path.
33
34 Ensure that the handler file for the application has the appropriate
35 permissions:
36
37 chmod u+x examples/CGI/SimpleHandler.py
38
39 With the above configuration, the "cookies" application should be visitable
40 with a URL resembling this one:
41
42 http://localhost/cgi/simple
43
44 Configuring AOLserver
45 =====================
46
47 To configure applications for AOLserver, edit the server's configuration file
48 (eg. config.tcl) so that definitions similar to the following are present in
49 the "CGI interface" section:
50
51 ns_section "ns/server/${servername}/module/nscgi"
52 ns_param map "GET /cgi /home/paulb/Software/Python/WebStack/examples/CGI" ;# CGI script file dir (GET).
53 ns_param map "POST /cgi /home/paulb/Software/Python/WebStack/examples/CGI" ;# CGI script file dir (POST).
54 ns_param interps CGIinterps
55
56 ns_section "ns/interps/CGIinterps"
57 ns_param .py "/usr/bin/python"
58
59 Search for the first line in the definitions above and add the following lines
60 immediately after it in the file.
61
62 Additionally, in the "Modules to load" section, starting with this line...
63
64 ns_section "ns/server/${servername}/modules"
65
66 ...you must ensure that the nscgi.so module is enabled:
67
68 ns_param nscgi ${bindir}/nscgi.so
69
70 In other words, it must not be commented out with a leading # character.
71
72 With the above configuration, the example applications should be visitable
73 with URLs resembling these:
74
75 http://localhost/cgi/CookieHandler.py
76 http://localhost/cgi/SimpleHandler.py
77
78 More advanced configuration of AOLserver to expose "cleaner" names for
79 application resources is not covered here.
80
81 Configuring lighttpd
82 ====================
83
84 To configure applications for lighttpd, edit the server's configuration file
85 (eg. lighttpd.conf) so that definitions similar to the following are present:
86
87 alias.url = ( "/cgi/" => "/home/paulb/Software/Python/WebStack/examples/CGI/" )
88 cgi.assign = ( ".py" => "" )
89
90 The latter line assumes that the permissions of the handler programs (eg.
91 SimpleHandler.py) are set correctly and that the first line of the programs
92 declares the Python runtime's whereabouts; for example:
93
94 #!/usr/bin/env python
95
96 To associate a specific Python runtime executable with the .py suffix, use a
97 line like the following instead:
98
99 cgi.assign = ( ".py" => "/usr/bin/python" )
100
101 More advanced configuration of lighttpd to expose "cleaner" names for
102 application resources is not covered here.
103
104 Session Storage with CGI
105 ========================
106
107 The very simple SessionStore class provided in WebStack.Helpers.Session, and
108 used by the WebStack.CGI.Transaction class, requires that a directory be
109 created in the directories of the CGI programs being run with the name
110 "WebStack-sessions". Here are some example commands for doing this:
111
112 cd examples/CGI
113 mkdir WebStack-sessions
114 chown username.groupname WebStack-sessions
115
116 The given "username" and "groupname" correspond to the user and group the Web
117 server assumes when running.