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 NOTE: AOLserver does not seem to handle "URL encoded" character values
48 NOTE: properly when such values appear in the path before the query string.
49
50 To configure applications for AOLserver, edit the server's configuration file
51 (eg. config.tcl) so that definitions similar to the following are present in
52 the "CGI interface" section:
53
54 ns_section "ns/server/${servername}/module/nscgi"
55 ns_param map "GET /cgi/simple /home/paulb/Software/Python/WebStack/examples/CGI/SimpleHandler.py" ;# CGI script file (GET).
56 ns_param map "POST /cgi/simple /home/paulb/Software/Python/WebStack/examples/CGI/SimpleHandler.py" ;# CGI script file (POST).
57 ns_param interps CGIinterps
58
59 ns_section "ns/interps/CGIinterps"
60 ns_param .py "/usr/bin/python"
61
62 Search for the first line in the definitions above and add the following lines
63 immediately after it in the file.
64
65 Additionally, in the "Modules to load" section, starting with this line...
66
67 ns_section "ns/server/${servername}/modules"
68
69 ...you must ensure that the nscgi.so module is enabled:
70
71 ns_param nscgi ${bindir}/nscgi.so
72
73 In other words, it must not be commented out with a leading # character.
74
75 With the above configuration, the example application should be visitable with
76 a URL resembling one of these:
77
78 http://192.168.1.100/cgi/simple
79 http://192.168.1.100:8000/cgi/simple
80
81 (Where 192.168.1.100 is the address that AOLserver is listening on - it does
82 not seem to enjoy listening on localhost.)
83
84 Configuring lighttpd
85 ====================
86
87 To configure applications for lighttpd, edit the server's configuration file
88 (eg. lighttpd.conf) so that definitions similar to the following are present:
89
90 alias.url = ( "/cgi/" => "/home/paulb/Software/Python/WebStack/examples/CGI/" )
91 cgi.assign = ( ".py" => "" )
92
93 The latter line assumes that the permissions of the handler programs (eg.
94 SimpleHandler.py) are set correctly and that the first line of the programs
95 declares the Python runtime's whereabouts; for example:
96
97 #!/usr/bin/env python
98
99 To associate a specific Python runtime executable with the .py suffix, use a
100 line like the following instead:
101
102 cgi.assign = ( ".py" => "/usr/bin/python" )
103
104 More advanced configuration of lighttpd to expose "cleaner" names for
105 application resources is not covered here.
106
107 Session Storage with CGI
108 ========================
109
110 The very simple SessionStore class provided in WebStack.Helpers.Session, and
111 used by the WebStack.CGI.Transaction class, requires that a directory be
112 created in the directories of the CGI programs being run with the name
113 "WebStack-sessions". Here are some example commands for doing this:
114
115 cd examples/CGI
116 mkdir WebStack-sessions
117 chown username.groupname WebStack-sessions
118
119 The given "username" and "groupname" correspond to the user and group the Web
120 server assumes when running.