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 the following definitions are present in the "CGI
49 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 Session Storage with CGI
82 ========================
83
84 The very simple SessionStore class provided in WebStack.Helpers.Session, and
85 used by the WebStack.CGI.Transaction class, requires that a directory be
86 created in the directories of the CGI programs being run with the name
87 "WebStack-sessions". Here are some example commands for doing this:
88
89 cd examples/CGI
90 mkdir WebStack-sessions
91 chown username.groupname WebStack-sessions
92
93 The given "username" and "groupname" correspond to the user and group the Web
94 server assumes when running.