我正在尝试将一些金字塔代码部署到dotcloud。不幸的是,有些路径的映射方式与本地paster部署不同。当我通过paster serve ...在本地服务器上运行开发配置时,我可以访问配置在:
config.add_static_view('static', 'appname:static')但是,在dotcloud服务器上,当脚本通过以下wsgi.py运行时
import os, sys
from paste.deploy import loadapp
current_dir = os.path.dirname(__file__)
application = loadapp('config:production.ini', relative_to=current_dir)在错误的目录中搜索静态内容。它应该在/home/dotcloud/current/appname/static/pylons.css中查找,而不是/home/dotcloud/current/static/pylons.css
wsgi配置中有没有可以定义基本目录的部分?我遗漏了什么?该应用程序通过nginx / uwsgi运行。
我试着加载config:../production.ini,relative_to=current_dir + '/appname',但这并没有改变任何事情。
发布于 2011-05-06 14:11:15
在DotCloud上,以/static开头的URL直接由nginx处理,而不是由uwsgi处理。这意味着您的代码永远看不到这些请求:它们将直接从应用程序的static/子目录中获得服务。
一种可能的解决方法是设置从static到appname/static的符号链接。
如果您不想让这样的符号链接弄乱您的存储库,您可以改用postinstall脚本:
#!/bin/sh
# This creates the symlink required by DotCloud to serve static content from nginx
ln -s ~/current/appname/static ~/current/static符号链接很流畅,但postinstall脚本允许您在文件中插入注释,以解释其用途:-)
DotCloud的未来版本可能会提供“裸配置”切换,其中nginx配置将不包括任何特殊的路径处理,以防您不需要它们。
同时,如果你想查看你的DotCloud服务的nginx默认配置,你可以通过dotcloud ssh连接到你的服务,并检查nginx。
https://stackoverflow.com/questions/5905291
复制相似问题