[mod_python] Connection Handler in a virtual host

Miikka Miettinen mmmietti at cs.Helsinki.FI
Mon Mar 1 16:31:46 EST 2004


> > <VirtualHost *:80>
> >     #this is an "ordinary web site"
> >     ServerName site1.xyz.org:80
> >     DocumentRoot /var/www/site1/htdocs
> >     #...
> > </VirtualHost>
> > 
> > <VirtualHost *:80>
> >     ServerName site2.xyz.org:80
> >     DocumentRoot /var/www/site2/htdocs
> >     PythonPath "sys.path+['/var/www/test']"
> >     PythonConnectionHandler conntest
> > </VirtualHost>
> 
> Why are you doing VirtualHost *:80 two times?

I guess different ServerName should be sufficient to identify the 
virtual host (and that part seems to work, since the sites have different 
document roots when I test them with a browser).

> Shouldn't it be:
> 
> <VirtualHost site1.xyz.org:80>
>      ServerName site1.xyz.org:80
>      DocumentRoot /var/www/site1/htdocs
> </VirtualHost>
> 
> <VirtualHost site2.xyz.org:80>
>      ServerName site2.xyz.org:80
>      DocumentRoot /var/www/site2/htdocs
>      PythonPath "sys.path+['/var/www/test']"
>      PythonConnectionHandler conntest
>  </VirtualHost>

If I try this (supplemented with "NameVirtualHost site1.xyz.org:80" and 
"NameVirtualHost site2.xyz.org:80"), I get the warning "NameVirtualHost 
site2.xyz.org:80 has no VirtualHosts". Again, both sites work and have 
different document roots, but the connection handler still isn't called.

If I understood the Apache documentation correctly, you normally use the 
server's IP address in the NameVirtualHost directive. I only have one IP 
address, so maybe I get the warning because both virtual hosts somehow 
look the same. But the document roots are different. Confusing.

Miikka



More information about the Mod_python mailing list