1 Configuring Apache
2 ==================
3
4 To configure applications without authenticators, use the config.py script
5 in tools/Apache to set up mod_python applications. For example:
6
7 python tools/Apache/config.py \
8 mod_python \
9 /home/paulb/Software/Python/WebStack/examples/ModPython/CookiesApp/CookiesHandler.py \
10 /etc/apache2/sites-available \
11 cookies-mod \
12 /cookies \
13 .cookies
14
15 This script can also be used to configure CGI applications. Run the script
16 without any arguments to see the documentation.
17
18 With the above command, the "cookies" application should be visitable with
19 URLs resembling these:
20
21 http://localhost/cookies/test.cookies
22 http://localhost/cookies/my.cookies
23
24 The Manual Approach
25 -------------------
26
27 For each application, add an Alias line to httpd.conf to point to the directory
28 containing the handler package, then specify the appropriate module name as the
29 PythonHandler.
30
31 Alias /simple "/home/paulb/Software/Python/WebStack/examples/ModPython/SimpleApp"
32
33 <Directory "/home/paulb/Software/Python/WebStack/examples/ModPython/SimpleApp">
34 AddHandler python-program .simple
35 PythonHandler SimpleHandler
36 PythonDebug On
37 </Directory>
38
39 It would appear that the directory really should be distinct from others
40 defined for mod_python, and that the handler should have a distinct name from
41 other handlers employed.
42
43 The WebStack package must reside on the PYTHONPATH, along with the package
44 containing the application itself. Therefore, ensure that the handler uses the
45 appropriate entries in sys.path.
46
47 Using the above definition in httpd.conf, only server resources residing
48 directly below "/simple" in the URL "hierarchy" with names ending in ".simple"
49 would be associated with the Simple WebStack application's resources.
50 Therefore, the following URL paths would access the application:
51
52 /simple/home.simple
53 /simple/tasks.simple/my-tasks
54 /simple/agenda.simple/tomorrow/first-thing
55
56 Examples of URL paths not addressing the application are as follows:
57
58 /agenda/my-agenda.simple
59 /simple/tasks/my-tasks.simple
60
61 Authentication/Authorisation in mod_python
62 ==========================================
63
64 Apache imposes fairly strict controls over authentication, requiring the
65 addition of various declarations in the configuration in order to impose
66 access controls on applications, and for WebStack authenticators to be used, a
67 "PythonAuthenHandler" must be declared in the application's configuration
68 section.
69
70 Consequently, it is necessary to define authentication methods in the
71 httpd.conf file as in the following example:
72
73 Alias /auth "/home/paulb/Software/Python/WebStack/examples/ModPython/AuthApp"
74
75 <Directory "/home/paulb/Software/Python/WebStack/examples/ModPython/AuthApp">
76 AddHandler python-program .py
77 PythonHandler AuthHandler
78 PythonAuthenHandler AuthHandler
79 PythonDebug On
80 AuthType Basic
81 AuthName "AuthResource"
82 AuthUserFile /usr/local/apache2/conf/users
83 require valid-user
84 </Directory>
85
86 The details of the application's deployment, including the exact pathname of
87 the users file and the appropriate access policy, must obviously be defined
88 according to the actual application concerned.
89
90 Session Storage with mod_python
91 ===============================
92
93 The very simple SessionStore class provided in WebStack.Helpers.Session, and
94 used by the WebStack.ModPython.Transaction class, requires that a directory be
95 created under the Apache server root with the name "WebStack-sessions". Here are
96 some example commands for doing this:
97
98 cd /usr/local/apache2
99 mkdir WebStack-sessions
100 chown username.groupname WebStack-sessions
101
102 The given "username" and "groupname" correspond to the user and group the Apache
103 server assumes when running.