简体   繁体   English

我的/ public目录可以是rails 3 + passenger 3 + nginx 0.8的符号链接吗?

[英]Can my /public directory be a symlink with rails 3 + passenger 3 + nginx 0.8?

I'm putting together a rails deployment where the public directory is a symlink to another directory on the system. 我正在组建一个rails部署,其中公共目录是系统上另一个目录的符号链接。 This is with passenger 3 on nginx .8. 这是nginx .8上的乘客3。 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. 默认情况下,Nginx总是遵循符号链接,所以AFAIK不是做与Apache的+ FollowSymLinks等效的事情。

update 更新

Looks like this is covered here: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#application_detection 看起来这里包括: http//www.modrails.com/documentation/Users%20guide%20Nginx.html#application_detection

Note that Phusion Passenger for Nginx does not resolve any symlinks in the root path. 请注意,Nginx的Phusion Passenger不会解析根路径中的任何符号链接。 So for example, suppose that your root points to /home/www/example.com, which in turn is a symlink to /webapps/example.com/public. 例如,假设您的根指向/home/www/example.com,而后者又是/webapps/example.com/public的符号链接。 Phusion Passenger for Nginx will check for /home/www/config/environment.rb, not /webapps/example.com/config/environment.rb. Nginx的Phusion Passenger将检查/home/www/config/environment.rb,而不是/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. 此文件当然不存在,因此Phusion Passenger不会为此虚拟主机激活自身,并且您很可能会看到Nginx默认目录处理程序生成的某些输出,例如Forbidden错误消息。

Detection of Rack applications happens through the same mechanism, exception that Phusion Passenger will look for config.ru instead of config/environment.rb. Rack应用程序的检测通过相同的机制进行,Phusion Passenger将寻找config.ru而不是config / environment.rb。

So I wonder if some proper symlinking of config.ru might do the trick. 所以我想知道是否有一些适当的配置符号可以解决这个问题。

Can't you use the following: 你不能使用以下内容:

mount --bind /original_path /your_ngnix_root_path

instead of using symlinks? 而不是使用符号链接? For ngnix it would be a usual directory, why it will point to another directory as you wanted it to be. 对于ngnix来说,这将是一个通常的目录,为什么它会指向你想要的另一个目录。

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/

For every new file or directory in /data/public you have to run this command again. 对于/ data / public中的每个新文件或目录,您必须再次运行此命令。

I was able to do this with the guide linked below. 我能够通过下面链接的指南来做到这一点。

  1. Create your rails app in /var/www/html /var/www/html创建rails应用程序
  2. Delete default . 删除default
  3. Edit the /etc/nginx/nginx.conf file 编辑/etc/nginx/nginx.conf文件
  4. symlink to sites-enabled 符号链接到sites-enabled
  5. Restart nginx 重启nginx

How to Deploy Ruby on Rails with Passenger and Nginx on Ubuntu 16.04 如何在Ubuntu 16.04上使用Passenger和Nginx部署Ruby on Rails

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM