0

我花了一整天的时间来解决这个问题,但我还没有得到它。我在 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站点-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;
    }

谁能告诉我,怎么了?请!

4

1 回答 1

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

希望这可以帮助!

于 2015-04-21T17:52:44.723 回答