2

我的 django 配置有奇怪的问题。我在一个 django 项目目录下运行了三个类似的站点。我用 apache virtualhost 将它们分开。它在大多数情况下运行良好,但有时不知何故在另一个域的一个域内容下。

例如 domain.cz 伪装成 www.microsite.cz。所以两个域下有相同的内容。或者 domain.sk 伪装成 domain.cz。它是随机发生的,很难调试。通常我可以从谷歌网站管理员工具中看到它。当apache重新启动时,一切正常。

有谁知道什么会导致这种奇怪的行为?

这是我的配置 httpd.conf:

ServerRoot "/home/me/webapps/domain/apache2"

LoadModule dir_module        modules/mod_dir.so
LoadModule env_module        modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module       modules/mod_mime.so
LoadModule rewrite_module    modules/mod_rewrite.so
LoadModule setenvif_module   modules/mod_setenvif.so
LoadModule wsgi_module       modules/mod_wsgi.so

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
KeepAlive Off
Listen 53696
SetEnvIf X-Forwarded-SSL on HTTPS=1


MaxSpareThreads 10
MinSpareThreads 2
ServerLimit 3
ThreadsPerChild 10

WSGIPythonPath /home/me/webapps/domain:/home/me/webapps/domain/lib/python2.6/site-packages


NameVirtualHost *
<VirtualHost *>
    ServerName domain.cz
    ServerAlias www.domain.cz

    CustomLog /home/me/logs/user/domain/access_com.log combined
    ErrorLog /home/me/logs/user/domain/error_com.log

    WSGIDaemonProcess domain_cz processes=3 python-path=/home/me/webapps/domain:/home/me/webapps/domain/lib/python2.6 threads=2
    WSGIScriptAlias / /home/me/webapps/domain/apache2/conf/cz.wsgi

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.domain\.cz$ [NC]
    RewriteRule ^/(.*)$ http://domain1.cz/$1 [R=301]
</VirtualHost>

<VirtualHost *>
    ServerName domain.sk
    ServerAlias www.domain.sk

    CustomLog /home/me/logs/user/domain/access_sk.log combined
    ErrorLog /home/me/logs/user/domain/error_sk.log

    WSGIDaemonProcess domain_sk python-path=/home/me/webapps/domain:/home/me/webapps/domain/lib/python2.6 threads=3
    WSGIScriptAlias / /home/me/webapps/domain/apache2/conf/sk.wsgi

    RewriteEngine on
    RewriteCond %{HTTP_HOST} slavne-domain\.sk$ [NC,OR]
    RewriteCond %{HTTP_HOST} slavnedomain\.sk$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www\.domain\.in$ [NC]
    RewriteRule ^/(.*)$ http://domain.in/$1 [R=301]
</VirtualHost>

<VirtualHost *>
    ServerName www.microsite.cz
    ServerAlias microsite.cz

    CustomLog /home/me/logs/user/domain/access_cz_laska.log combined
    ErrorLog /home/me/logs/user/domain/error_cz_laska.log

    WSGIDaemonProcess domain_cz_micro python-path=/home/me/webapps/domain:/home/me/webapps/domain/lib/python2.6 threads=3
    WSGIScriptAlias / /home/me/webapps/domain/apache2/conf/cz_micro.wsgi

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^domain-o-lasce\.net$ [NC]
    RewriteRule ^/(.*)$ http://www.domain-o-lasce.net/$1 [R=301]
</VirtualHost>

这是我的 wsgi 脚本的示例:

import os
import sys

from django.core.handlers.wsgi import WSGIHandler

os.environ['DJANGO_SETTINGS_MODULE'] = 'domain.settings.cz'
# or domain.settings.sk or domain.settings.cz_micro 

application = WSGIHandler()
4

1 回答 1

1

您缺少 WSGIProcessGroup 指令。去阅读:

您的单独应用程序并没有像您想象的那样在单独的进程中运行。

于 2013-05-27T22:21:23.120 回答