【发布时间】:2012-11-25 01:04:38
【问题描述】:
我正在尝试使用 WSGI 部署在 Apache 上部署 Django(位于 virtualenv 中)。我正在关注https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/ 的默认教程
wsgi.py(Django 生成的默认文件,删除了 cmets):
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
apache2.conf(与 Debian 中的 httpd.conf 相同)。将此附加到末尾:
WSGIScriptAlias / /home/user/Desktop/expofit/expofit_hg/py/server/server/wsgi.py
WSGIDaemonProcess example.com python-path=/home/user/Desktop/expofit/expofit_hg/py/server:/home/user/Desktop/expofit/expofit_env/lib/python2.7/site-packages
WSGIProcessGroup example.com
<Directory /home/user/Desktop/expofit/expofit_hg/py/server/server>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
Alias /static/ /home/user/Desktop/expofit/expofit_hg/py/server/server/static
<Directory /home/user/Desktop/expofit/expofit_hg/py/server/server/static>
Order deny,allow
Allow from all
</Directory>
但是,这以错误结束:
[Thu Dec 06 17:08:40 2012] [error] [client 192.168.56.1] ImportError: No module named django.core.wsgi
看来标准的python是可以访问的,因为
import os
不会产生错误。所以似乎从 virtualenv 导入的模块是不可导入的。 教程说:
如果您使用上述配置,则需要进一步更改 守护进程模式是你不能使用 WSGIPythonPath;相反,你应该 使用 WSGIDaemonProcess 的 python-path 选项,例如:
WSGIDaemonProcess example.com python-path=/path/to/mysite.com:/path/to/venv/lib/python2.7/site-packages
WSGIProcessGroup example.com
我错过了什么?
【问题讨论】:
标签: django mod-wsgi wsgi django-wsgi