![](/img/trans.png)
[英]Rails + Unicorn + Nginx + Capistrano 3 + Linode VPS: Not Recognizing Staging Environment
[英]Ruby on rails nginx , unicorn, capistrano vps hosting error
嗨,我正在学习如何在VPS中部署Rails应用程序,本教程遵循https://coderwall.com/p/yz8cha ,并且一切正常,我发现了一些错误,并通过搜索网络对其进行了更正,并且一切正常capistrano将文件和文件夹部署到VPS,如果我更改任何代码,则在cap cap部署后,它也将在VPS中更改,一切正常,终端上没有显示错误,但是问题是nginx服务器未运行(在初始阶段它显示其索引页-欢迎来到nginx),我不知道可能在哪里发生问题,我将做的任何帮助将不胜感激,我正在使用Rails 4.1.4,ruby 2.1.2,capistrano( 2.15.5)是否重要
我不知道必须在此处显示哪个代码如果您想查看任何代码,我很想向您显示....这是我的nginx.conf文件
upstream unicorn {
server unix:/tmp/unicorn.projectname.sock fail_timeout=0;
}
server {
listen 80 default_server deferred;
# server_name example.com;
root /home/administrator/apps/testvps/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
keepalive_timeout 10;
}
这是我在VPS终端中的nginx -t
时遇到的错误
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2014/08/01 15:40:35 [warn] 5682#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
2014/08/01 15:40:35 [emerg] 5682#0: open() "/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed
根据nginx -t
所示的错误,用户无权写入nginx日志文件。
尝试以root用户sudo nginx -t
nginx -t
身份运行nginx -t
,如果仍然显示权限错误,请尝试更新权限:
sudo chown -R www-data:www-data /var/log/nginx;
sudo chmod -R 755 /var/log/nginx;
编辑:
根据我们的讨论,您的nginx配置已成功设置。 现在,您在访问应用程序时会看到空白页。
您需要将root
添加到routes.rb
文件中。 Rails 4没有public/index.html
文件。 因此,您看到的是空白页。 设置root
您将能够看到您的主页。
您进一步怀疑:
所以这是nginx.conf文件的根目录/ home / administrator / apps / testvps / current / public;
我应该这样改变吗:root / home / administrator / apps / testvps / current;
不,nginx应该查找您的应用程序public
目录。 如routes.rb
所述,将请求导航到root_path
是Rails的责任
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.