![](/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.