我的/public 目录可以是带有 rails 3 +passenger 3 + nginx 0.8 的符号链接吗? [英] Can my /public directory be a symlink with rails 3 + passenger 3 + nginx 0.8?

查看:19
本文介绍了我的/public 目录可以是带有 rails 3 +passenger 3 + nginx 0.8 的符号链接吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在整理一个 Rails 部署,其中公共目录是一个符号链接到系统上的另一个目录.这是乘客 3nginx .8.它似乎不喜欢这种设置.默认情况下,Nginx 始终遵循符号链接,因此 AFAIK 与执行 Apache 的 +FollowSymLinks 等价无关.

I'm putting together a rails deployment where the public directory is a symlink to another directory on the system. This is with passenger 3 on nginx .8. It does't seem to like that setup. Nginx always follows symlinks by default, so AFAIK it's not a matter of doing the equivalent of Apache's +FollowSymLinks.

更新

看起来这里有介绍:http://www.modrails.com/documentation/Users%20guide%20Nginx.html#application_detection

注意 Nginx 的 Phusion 乘客不解析任何符号链接根路径.例如,假设你的根指向/home/www/example.com,反过来是一个符号链接/webapps/example.com/public.合欢Nginx 的乘客将检查/home/www/config/environment.rb,不是/webapps/example.com/config/environment.rb.这个文件当然不存在,而且因此 Phusion 乘客不会为这个虚拟主机激活自己,你很可能会看到一些输出由 Nginx 默认生成目录处理程序,例如 Forbidden错误信息.

Note that Phusion Passenger for Nginx does not resolve any symlinks in the root path. So for example, suppose that your root points to /home/www/example.com, which in turn is a symlink to /webapps/example.com/public. Phusion Passenger for Nginx will check for /home/www/config/environment.rb, not /webapps/example.com/config/environment.rb. This file of course doesn’t exist, and as a result Phusion Passenger will not activate itself for this virtual host, and you’ll most likely see some output generated by the Nginx default directory handler such as a Forbidden error message.

检测到 Rack 应用程序通过相同的机制,异常Phusion 乘客会寻找config.ru 而不是配置/环境.rb.

Detection of Rack applications happens through the same mechanism, exception that Phusion Passenger will look for config.ru instead of config/environment.rb.

所以我想知道 config.ru 的一些适当的符号链接是否可以解决问题.

So I wonder if some proper symlinking of config.ru might do the trick.

推荐答案

我认为不可能使用符号链接的公共目录.我能想到的唯一解决方法是对公共目录中的任何文件和目录进行符号链接.

I think it is not possible to use a symlinked public directory. The only workaround I can imagine is to symlink any file and directory inside of the public dir.

# public folder: /data/public
# app folder: /webapp/
mkdir -p /webapp/public && ln -sf /data/public/* /webapp/public/

对于/data/public 中的每个新文件或目录,您必须再次运行此命令.

For every new file or directory in /data/public you have to run this command again.

这篇关于我的/public 目录可以是带有 rails 3 +passenger 3 + nginx 0.8 的符号链接吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆