我试图在linode VPS上部署rails应用程序。出于部署目的,我创建了deployer
用户。
我已经使用rvm安装了ruby / rails / passenger。
我的/opt/nginx/conf/nginx.conf如下:
http {
passenger_root /home/deployer/.rvm/gems/ruby-2.1.3/gems/passenger-4.0.52;
passenger_ruby /home/deployer/.rvm/rubies/ruby-2.1.3/bin/ruby;
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
server {
listen 80;
server_name myserver;
passenger_enabled on;
rails_env production;
root /var/www/your_own_store/current/public;
#charset koi8-r;
#access_log logs/host.access.log main;
nginx重启后,我得到了403页。而error.log如下:
2014/09/30 13:33:24 [error] 27388#0: *27 directory index of "/var/www/your_own_store/current/public/" is forbidden, client: 1.39.62.158, server: myserver, request: "GET / HTTP/1.1", host: "myhost"
经过近两天的调试后,我觉得问题可能是因为:
连接到服务器后,除非我
$ source ~/.bash_profile
我看到我的rails版本为1.9.3。乘客安装在不同的地方,如下图所示:
root@localhost:/opt/nginx/logs# passenger-config --root
/var/lib/gems/1.9.1/gems/passenger-4.0.52
root@localhost:/opt/nginx/logs# su deployer
deployer@localhost:/opt/nginx/logs$ passenger-config --root
/var/lib/gems/1.9.1/gems/passenger-4.0.52
deployer@localhost:/opt/nginx/logs$ source ~/.bashrc
deployer@localhost:/opt/nginx/logs$ passenger-config --root
/var/lib/gems/1.9.1/gems/passenger-4.0.52
deployer@localhost:/opt/nginx/logs$ source ~/.bash_profile
deployer@localhost:/opt/nginx/logs$ passenger-config --root
/home/deployer/.rvm/gems/ruby-2.1.3/gems/passenger-4.0.52
root@localhost:/opt/nginx/conf# ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
root@localhost:/opt/nginx/conf# su deployer
deployer@localhost:/opt/nginx/conf$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
deployer@localhost:/opt/nginx/conf$ source ~/.bash_profile
deployer@localhost:/opt/nginx/conf$ ruby -v
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]
我不确定这是否是问题的根本原因。如果是这样,如何解决?
早些时候,我已将所有内容安装为root
,它的工作方式就像魅力一样。
有人可以帮我吗?
由于
更新:我可以找到默认ruby设置的解决方案。 原因是,当以用户身份登录时,系统会提供.bash_profile,而如果我这样做,那就是非登录shell。所以它只是源.bashrc而不是.bash_profile。
所以在将以下行添加到.bashrc之后,我可以在' su'之后找到正确的ruby版本。 [[-s" $ HOME / .rvm / scripts / rvm" ]]&&来源" $ HOME / .rvm / scripts / rvm" #将RVM加载到shell会话中作为函数
Here是我在unix.stackexchange上找到的解释的参考。
答案 0 :(得分:0)
显然,我通过引用网络上提供的多个文档搞砸了一些东西。我只是重建服务器并按照正确的步骤(我将尽快在博客中发布所有步骤)。所有工作都像魅力:)