【问题标题】:django wsgi correct configuration on vhostsdjango wsgi 在 vhosts 上正确配置
【发布时间】:2014-06-08 08:42:05
【问题描述】:

我想将我的工作应用程序放在 apache2 vhosts (Ubuntu) 上,其他带有 php 的主机工作正常,但我的问题是 django。我有 500 个内部 /home/py/django/kitty/kitty/wsgi.py

import os
import sys
sys.path.append('/home/s/py/django/kitty')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "kitty.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

/etc/apache2/sites-available/wiersze.td.conf

<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName  wiersze.td
#DocumentRoot /
WSGIScriptAlias / /home/s/py/django/kitty/kitty/wsgi.py
Alias /adminmedia/  /opt/python2.7/lib/python2.7/site-packages/django/contrib/admin/media/
<Directory "/home/s/py/django/kitty/kitty/">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
</VirtualHost>

并且在error.log中

...
ImportError: Could not import settings 'kitty.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named kitty.settings
...

【问题讨论】:

    标签: python django apache2 mod-wsgi


    【解决方案1】:

    在你wsgi.py 你正在导入kitty.settings 那些不在你的python 路径上。

    1. 按以下方式编辑您的 wsgi.py:

      path = '/path/to/kitty' 如果路径不在 sys.path 中: sys.path.append(路径)

    另见:

    https://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-14
      • 2011-03-04
      • 2015-07-24
      • 1970-01-01
      • 1970-01-01
      • 2012-04-27
      相关资源
      最近更新 更多