[mod_python] VirtualDocumentRoot, PythonPath and Subinterpreters

Troy Kruthoff tkruthoff at gmail.com
Tue Jan 31 02:36:34 EST 2006

How does one go about getting mod_python to know the DocumentRoot when
using the apache VirtualDocumentRoot directive?  Below is a my vhost
conf showing what I am trying to accomplish (I'm trying to get the
PythonPath to match the VirtualDocumentRoot:

<VirtualHost *:80>
    ServerAdmin webmas... at dummy-host.example.com
    UseCanonicalName Off
    VirtualDocumentRoot /www/vhosts/%0

    DirectoryIndex index.py
    PythonPath "sys.path+['/www/vhosts/%0']"
    AddHandler mod_python .py
    PythonHandler index
    PythonDebug On
    ServerName *.example.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common

This type of setup makes it viable to run thousands of vhosts from a
single httpd.conf file, and allows the addition and deletion of vhosts
without restarting apache.  This brings me to another point.  If we
are planning to use the worker MPM, a sub-interpreter will be created
for each vhost.  I'm assuming if we can get VirtualDocumentRoot to
work, that the same will apply.  Does anyone know:

1)  How many sub-interpreters is too much?
2)  Is there a way to monitor sub-interpreters and kill stale ones?



More information about the Mod_python mailing list