The last step in the installation process is to define web applications in the Apache configuration file. A Draco web application has the following properties:
The recommended installation is that you use one virtual host per Draco
application. Because by default mod_python uses one Python interpreter per
virtual host, you don't have to tweak its PythonInterpreter
settings
in this case. For the rest of the section we will assume that we are
configuring Draco in this way.
To define a Draco web application, add the following fragment to your httpd.conf:
LoadModule python_module MODPYTHON_PATH/mod_python.so <VirtualHost myhost> AddHandler python-program .dsp PythonHandler draco.dracohandler PythonAccessHandler draco.dracohandler PythonOption DocumentRoot DOCUMENTROOT DirectoryIndex index.dsp </VirtualHost>
Let's discuss these commands one by one:
LoadModule python_module MODPYTHON_PATH/mod_python.so
This line instructs Apache to load mod_python. MODPYTHON_PATH
should be changed to the directory where you installed mod_python. If you
compiled mod_python statically, you don't need this line.
AddHandler python-program .dsp PythonHandler draco.dracohandler PythonAccessHandler draco.dracohandler
The first line above tells that Apache should use mod_python for all files
in the web space of the virtual host having the extension .dsp
. By
convention, draco files have the extension .dsp, which stands for
Draco Server Page. This extension can be changed in the configuration
file2.1. The second and third line
tell mod_python to use Draco as the content and access handler
respectively. The content handler is the handler that takes care of
generating content. The access handler is used to filter out certain files
from the webspace that should not be public, like handler code and the
configuration file.
PythonOption DocumentRoot DOCUMENTROOT
Here we notify Draco of the document root of the web space. You must specify
the same value as the DocumentRoot
directive of your virtual host
definition. Due to an implementation quirk, this value is not directly
accessible to Draco, so it must be passed explicitly through a
PythonOption
.
DirectoryIndex index.dsp
This directive tells Apache to use the file index.dsp as the default directory index.
At this point Draco is ready to be tested. Please be sure to restart Apache so that the new configuration is loaded. Now put the following fragment in a file called index.dsp in the document root of your web site:
<html> <head> <title>Hello, world!</title> </head> <body> <p> <% print "Hello, world!" %> </body> </html>
Now access your web site with a browser. If you are greeted in a friendly way, you have successfully set up Draco. If there is an error, Draco will (hopefully) give you an error message to indicate the problem.
AddHandler
line too.