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