django请求搞砸了?

时间:2011-03-21 15:51:53

标签: python django apache

我有3个具有不同设置的django项目,2个子域下的parents.abc.com,teachers.abc.com and abc.com.它们都属于共享的apache实例。这是我的httpd配置文件:

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home/user/logs/user/access_django.log combined
ErrorLog /home/user/logs/user/error_django.log
KeepAlive Off
Listen 37049
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
WSGIDaemonProcess django processes=5 python-path=/home/user/webapps/django:/home/user/webapps/django/lib/python2.6 threads=1
WSGIPythonPath /home/user/webapps/django:/home/user/webapps/django/lib/python2.6
NameVirtualHost *:37049

<VirtualHost *:37049>
        WSGIScriptAlias / /home/user/webapps/django/abc.wsgi
        ServerName abc.com
        ServerAlias abc.com
</VirtualHost>
<VirtualHost *:37049>
        WSGIScriptAlias / /home/user/webapps/django/parents.wsgi
        ServerAlias parents.abc.com
</VirtualHost>

<VirtualHost *:37049>
        WSGIScriptAlias / /home/user/webapps/django/teachers.wsgi
        ServerAlias teachers.abc.com
</VirtualHost>

我的问题来了(重启后)如果我访问parents.abc.com,然后是teachers.abc.com(反之亦然),我会在第二次遇到网址错误,因为它似乎引用了网址第一个项目的.py。即teachers.abc.com正在查看parents.abc.com的设置文件(反之亦然)。

任何人都可以对此有所了解吗?

1 个答案:

答案 0 :(得分:1)

我认为你需要在每个vhost中指定服务器名称

加入:

ServerName parents.abc.com

ServerName teachers.abc.com
据我所知,ServerAlias本身不足以定义基于名称的虚拟主机。