Django 1.9 + Dreamhost 上的 Passenger:Web 应用程序无法启动
Django 1.9 + Passenger on Dreamhost: Web application could not be started
我正在尝试在 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 启动,当我访问该站点时,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
我真的不明白 Passenger 是如何工作的,我认为问题与 this 有关,但我不知道如何让它工作。
如有任何帮助,我们将不胜感激。非常感谢。
这已通过在 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()
我正在尝试在 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 启动,当我访问该站点时,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
我真的不明白 Passenger 是如何工作的,我认为问题与 this 有关,但我不知道如何让它工作。
如有任何帮助,我们将不胜感激。非常感谢。
这已通过在 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()