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