【问题标题】:Django 1.9 + Passenger on Dreamhost: Web application could not be startedDreamhost 上的 Django 1.9 + 乘客:无法启动 Web 应用程序
【发布时间】:2016-11-12 14:34:08
【问题描述】:

我正在尝试在 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有关,但我不知道如何让它工作。

任何帮助将不胜感激。非常感谢。

【问题讨论】:

    标签: python django passenger dreamhost


    【解决方案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()
    

    【讨论】:

    • 你是在 DreamHost VPS 还是其他什么产品上运行这个?
    • 嗨! Dreamhost 共享主机
    猜你喜欢
    • 2015-12-06
    • 1970-01-01
    • 1970-01-01
    • 2012-10-15
    • 1970-01-01
    • 2014-07-07
    • 1970-01-01
    • 2019-07-31
    • 2014-03-13
    相关资源
    最近更新 更多