如何让 Phusion Passenger 与 Django for App Engine 配合使用?

发布于 2024-09-01 08:39:58 字数 269 浏览 10 评论 0原文

我在让 Phusion Passenger 与 django-nonrel 一起用于 Google 的 App Engine 时遇到了困难。我似乎可以让它为 GoogleAppEngineLauncher 和生产服务器工作,但不能为 Passenger 工作;或适用于 Passenger 和 GoogleAppEngineLauncher,但不适用于生产服务器;或适用于 Passenger 和生产服务器,但不适用于 GoogleAppEngineLauncher。

如何让我的应用程序部署在这三个平台上?

I'm having a devil of a time getting Phusion Passenger to work with django-nonrel for Google's App Engine. I can seem to get it to work for GoogleAppEngineLauncher and for the production server but not Passenger; or for Passenger and GoogleAppEngineLauncher but not the production server; or for Passenger and the production server but not GoogleAppEngineLauncher.

How do I get my app to deploy on all three?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

肩上的翅膀 2024-09-08 08:39:58

这是我需要在 Mac OS X Snow Leopard 上执行的操作:

  1. 将 djangoappengine 目录直接放在“ROOT/common-apps”中。如果将其放在 common-apps 目录之外,appengine 可能会感到困惑,并使用 djangoappengine 目录作为 PROJECT_DIR,而不是使用 ROOT 作为 PROJECT_DIR。您可能还需要将 init.py 添加到您的 common-apps 目录中。
  2. 将 django-nonrel 放在 ROOT 目录之外,并创建从 ROOT/common-apps/django 到 NONROOT/django-nonrel/django 的符号链接。如果您将 django-nonrel 直接放入 common-apps 目录中,则在部署时可能会超过 app-engine 上的 3000 个文件上传限制。
  3. 创建一个空的 ROOT/public 目录。 Passenger 使用此目录的父目录作为项目根目录。
  4. 按如下方式配置您的 apache vhost,假设 MYAPPNAME.local 是您的 /etc/hosts
  5. 创建 Passenger_wsgi.py 并将其放入您的 ROOT 目录中,如下所示。

vhosts:

<VirtualHost *:80>
   ServerName MYAPPNAME.local
   DocumentRoot /Users/mike/Projects/ROOT/public
    <Directory  /Users/mike/Projects/ROOT/public>
      AllowOverride all
      Options -MultiViews
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>

passenger_wsgi.py:

import os, sys

# BUG there must be a better way than listing everything individually...
sys.path.append('/Users/mike/Projects/ROOT/')
sys.path.append('/Users/mike/Projects/ROOT/common-apps/')
sys.path.append('/Users/mike/Projects/NONROOT/django-nonrel/')
sys.path.append('/usr/local/google_appengine/')
sys.path.append('/usr/local/google_appengine/lib/yaml/lib/')
sys.path.append('/usr/local/google_appengine/lib/antlr3/')
sys.path.append('/usr/local/google_appengine/lib/django/')
sys.path.append('/usr/local/google_appengine/lib/cacerts/')
sys.path.append('/usr/local/google_appengine/lib/ipaddr/')
sys.path.append('/usr/local/google_appengine/lib/webob/')
sys.path.append('/usr/local/google_appengine/google/appengine/api/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

希望我没有遗漏任何重要的内容。

Here's what I needed to do on Mac OS X Snow Leopard:

  1. Put the djangoappengine directory directly in 'ROOT/common-apps'. If you put it outside of your common-apps directory, appengine may get confused and use the djangoappengine dir as your PROJECT_DIR instead of using ROOT as your PROJECT_DIR. You may also need to add an init.py to your common-apps directory.
  2. Put the django-nonrel OUTSIDE of the ROOT directory, and make a symlink from ROOT/common-apps/django to NONROOT/django-nonrel/django. If you put django-nonrel directly into your common-apps directory you'll probably exceed the 3000 file upload limit on app-engine when you go to deploy.
  3. Create an empty ROOT/public directory. Passenger uses the parent of this directory as the project root.
  4. Configure your apache vhost as below, assuming that MYAPPNAME.local is your /etc/hosts
  5. Create passenger_wsgi.py and put it in your ROOT directory as below.

vhosts:

<VirtualHost *:80>
   ServerName MYAPPNAME.local
   DocumentRoot /Users/mike/Projects/ROOT/public
    <Directory  /Users/mike/Projects/ROOT/public>
      AllowOverride all
      Options -MultiViews
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>

passenger_wsgi.py:

import os, sys

# BUG there must be a better way than listing everything individually...
sys.path.append('/Users/mike/Projects/ROOT/')
sys.path.append('/Users/mike/Projects/ROOT/common-apps/')
sys.path.append('/Users/mike/Projects/NONROOT/django-nonrel/')
sys.path.append('/usr/local/google_appengine/')
sys.path.append('/usr/local/google_appengine/lib/yaml/lib/')
sys.path.append('/usr/local/google_appengine/lib/antlr3/')
sys.path.append('/usr/local/google_appengine/lib/django/')
sys.path.append('/usr/local/google_appengine/lib/cacerts/')
sys.path.append('/usr/local/google_appengine/lib/ipaddr/')
sys.path.append('/usr/local/google_appengine/lib/webob/')
sys.path.append('/usr/local/google_appengine/google/appengine/api/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Hopefully I didn't leave anything significant out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文