我正在尝试在Dreamhost共享主机上使用Django 1.9(使用Python 3.4)。
我遵循了这个教程: https://brobin.me/blog/2015/03/deploying-django-with-virtualenv-on-dreamhost/
现在我的passenger_wsgi.py是这样的:
import sys, os
cwd = os.getcwd()
sys.path.append(cwd)
sys.path.append(cwd + '/my_project')
INTERP = os.path.expanduser("~/venv/bin/python")
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
sys.path.insert(0,'$HOME/venv/bin')
sys.path.insert(0,'$HOME/venv/lib/python3.4/site-packages/django')
sys.path.insert(0,'$HOME/venv/lib/python3.4/site-packages')
os.environ['DJANGO_SETTINGS_MODULE'] = "my_project.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
问题是乘客启动,当我去网站时,Passenger显示此错误:
Web application could not be started
An error occurred while starting the web application. It exited before signalling successful startup back to Phusion Passenger. Please read this article for more information about this problem.
Raw process output:
Traceback (most recent call last):
File "/dh/passenger/helper-scripts/wsgi-loader.py", line 320, in <module>
app_module = load_app()
File "/dh/passenger/helper-scripts/wsgi-loader.py", line 61, in load_app
return imp.load_source('passenger_wsgi', startup_file)
File "passenger_wsgi.py", line 8, in <module>
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
File "/usr/lib/python2.7/os.py", line 312, in execl
execv(file, args)
OSError: [Errno 2] No such file or directory
我真的不明白乘客是如何工作的,我认为这个问题与this有关,但我无法弄清楚如何让它发挥作用。
任何帮助将不胜感激。非常感谢你。
答案 0 :(得分:1)
通过使用passenger_wsgi.py中的正确设置解决了这个问题:
import sys, os
cwd = os.getcwd()
sys.path.append(cwd)
project_location = cwd + '/my_project'
sys.path.insert(0,project_location)
INTERP = os.path.expanduser("/home/user/python/Python-3.4.3/venv/bin/python")
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
sys.path.insert(0,'$HOME/python/Python-3.4.3/venv/bin')
sys.path.insert(0,'$HOME/python/Python-3.4.3/venv/lib/python3.4/site-packages/django')
sys.path.insert(0,'$HOME/python/Python-3.4.3/venv/lib/python3.4/site-packages')
os.environ['DJANGO_SETTINGS_MODULE'] = "my_project.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()