Rails应用程序呈现白色空白页! Unicorn + Nginx + mina

时间:2015-04-21 15:49:29

标签: ruby-on-rails nginx rvm unicorn mina

我花了整整一天的时间来解决这个问题,但我还没有得到它。 我在digitaloceon中创建了一个Droplet,我安装了rvm并使用mina部署了我的rails应用程序。我创建了交换区域。

所以,我确信我的应用程序路径在nginx配置和routes.rb中是正确的。但是rails也在我的域名和服务器IP上呈现了一个空白的白页。

我检查了unicorn.stder.log我看到了这些日志:

Instance method "open" is already defined in Object, use generic helper instead or set StateMachine::Machine.ignore_method_conflicts = true. 
I, [2015-04-21T14:35:55.148457 #18765]  INFO -- : listening on addr=/tmp/unicorn.sock fd=12
I, [2015-04-21T14:35:55.169044 #18765]  INFO -- : master process ready
I, [2015-04-21T14:35:55.186923 #18769]  INFO -- : worker=0 ready
I, [2015-04-21T14:35:55.195608 #18772]  INFO -- : worker=1 ready
E, [2015-04-21T14:35:58.821812 #18769] ERROR -- : app error: (<unknown>): mapping values are not allowed in this context at line 8 column 56 (Psych::SyntaxError)
E, [2015-04-21T14:35:58.821983 #18769] ERROR -- : /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:370:in `parse'
E, [2015-04-21T14:35:58.822057 #18769] ERROR -- : /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:370:in `parse_stream'
E, [2015-04-21T14:35:58.822106 #18769] ERROR -- : /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:318:in `parse'
E, [2015-04-21T14:35:58.822141 #18769] ERROR -- : /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:245:in `load'
E, [2015-04-21T14:35:58.822174 #18769] ERROR -- : /var/www/myapp/current/vendor/bundle/ruby/2.1.0/gems/railties-4.1.9/lib/rails/application.rb:339:in `secrets'
E, [2015-04-21T14:35:58.822216 #18769] ERROR -- : /var/www/myapp/current/vendor/bundle/ruby/2.1.0/gems/railties-4.1.9/lib/rails/application.rb:477:in `validate_secret_key_config!'
E, [2015-04-21T14:35:58.822251 #18769] ERROR -- : /var/www/myapp/current/vendor/bundle/ruby/2.1.0/gems/railties-4.1.9/lib/rails/application.rb:195:in `env_config'
E, [2015-04-21T14:35:58.822301 #18769] ERROR -- : /var/www/myapp/current/vendor/bundle/ruby/2.1.0/gems/railties-4.1.9/lib/rails/engine.rb:510:in `call'

所以这是我的nginx sites-available / myapp.com

upstream app {
    # Path to Unicorn SOCK file, as defined previously
    server unix:/tmp/unicorn.sock fail_timeout=0;
}

server {


    listen 80;
    server_name .mydomain.com;

    # Application root, as defined previously
    root /var/www/myapp/current/public;

    try_files $uri/index.html $uri @app;

    location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
    }

谁能告诉我,有什么问题?请!

1 个答案:

答案 0 :(得分:0)

查看此修订后的nginx配置是否有效

upstream app {
  # Path to Unicorn SOCK file, as defined previously
  server unix:/tmp/unicorn.sock fail_timeout=0;
}

server {


  listen 80;
  server_name mercandiamond.com www.mercandiamond.com;

  # Application root, as defined previously
  root /var/www/myapp/current/public;

  location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://localhost:22/;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
}

如果没有,请确保

1)sites-enabled / myapp.com匹配sites-available / myapp.com

2)运行nginx -s reload

希望这有帮助!