使用apache mod_wsgi的Django多个站点:请求访问错误的站点

时间:2014-06-04 19:50:20

标签: django apache mod-wsgi virtualhost

我正在尝试使用带有mod_wsgi的虚拟主机从一个apache服务器运行2个Django站点。问题是我的所有请求都会转到同一个Django站点(可能是Apache加载的第一个站点),即使我使用其他站点的主机名也是如此。我的网站是

https://staging-test.mydomain.com

https://staging.mydomain.com

以下是我的虚拟主机文件的内容。我已经创建了两个部署文件,我将其放在Apache安装的site-enabled目录(Ubuntu)中。两个文件,因为它有助于dev-ops。无论如何,配置看起来像

<VirtualHost _default_:443>
    ServerAdmin webmaster@localhost
    ServerName https://staging-test.mydomain.com
    SetEnv PYTHON_EGG_CACHE /tmp
    WSGIDaemonProcess https://staging-test.mydomain.com user=www-data group=www-data processes=10 threads=1 python-path=/home/talha/site1 display-name=wsgid
    WSGIProcessGroup https://staging-test.mydomain.com
    WSGIScriptAlias / /home/talha/site1/wsgi.py process-group=https://staging-test.mydomain.com application-group=%{RESOURCE}
    WSGIPassAuthorization On
    WSGIApplicationGroup %{RESOURCE}
</VirtualHost>

<VirtualHost _default_:443>
    ServerAdmin webmaster@localhost
    ServerName https://staging.mydomain.com
    SetEnv PYTHON_EGG_CACHE /tmp
    WSGIDaemonProcess https://staging.mydomain.com user=www-data group=www-data processes=10 threads=1 python-path=/home/talha/site2 display-name=wsgid
    WSGIProcessGroup https://staging.mydomain.com
    WSGIScriptAlias / /home/talha/site2/wsgi.py process-group=https://staging.mydomain.com application-group=%{RESOURCE}
    WSGIPassAuthorization On
    WSGIApplicationGroup %{RESOURCE}
</VirtualHost>     

我尝试使用WSGIDaemonProcessWSGIProcessGroup来使网站在不同的进程中运行,但请求仍然只包含其中一个。

任何想法可能在这里出错?

1 个答案:

答案 0 :(得分:1)

有人指出,你最初的问题是你不应该在ServerName中使用URI,它必须只是主机名。除了解决这个问题,请确保阅读:

由于ServerName设置错误,您正在尝试该帖子中描述的默认VirtualHost问题的变体。

相关问题