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