0

リモート サーバーにベアボーン Rails をデプロイしましたが、スタイルが表示されません。ページのソースを確認すると、スタイルシートへのリンクがあります (twitter の bootstrap gem を使用しています)。

 <link href="/assets/application-99190f98350e7ed3bb886d20f87bedfd.css" media="all" rel="stylesheet" />

しかし、リンクをクリックすると、404 Not Found が表示されます

http://162.XXX.XXX/assets/application-99190f98350e7ed3bb886d20f87bedfd.css

 404 Not Found

nginx/1.4.3

ジャバスクリプトも同様です。

Ryan BatesがRailscastsの「Deploying to a VPS」 http://railscasts.com/episodes/335-deploying-to-a-vps?view=で説明する方法に従って構成された、ubuntuサーバーでNGINXとUnicornを使用しています。アシキャスト。リモートサーバーでcssファイルを表示すると、すべてのスタイルが含まれています...

問題が何であるかを知っている人はいますか?アプリケーション レイアウト ファイルでスタイルシートへのフル パスを指定するにはどうすればよいですか? それは問題を回避しますか?

/*
  =require twitter-bootstrap-static/bootstrap

  Use Font Awesome icons (default)
  To use Glyphicons sprites instead of Font Awesome, replace with "require twitter-bootstrap-static/sprites"
  =require twitter-bootstrap-static/fontawesome
  */


  html,
      body {
        height: 100%;
       /*   background-color: #;*/
        /* The html and body elements cannot have any padding or margin. */
      }

      /* Wrapper for page content to push down footer */
      #wrap {
        min-height: 100%;
        height: auto !important;
        height: 100%;
        /* Negative indent footer by it's height */
        margin: 0 auto -60px;
      }

      /* Set the fixed height of the footer here */
      #push,
      #footer {
        height: 60px;
      }
      #footer {
        background-color: rgb(245, 240, 240);
      }

      /* Lastly, apply responsive CSS fixes as necessary */
      @media (max-width: 767px) {
        #footer {
          margin-left: -20px;
          margin-right: -20px;
          padding-left: 20px;
          padding-right: 20px;
        }
      }

      #wrap > .container {
        padding-top: 60px;
      }

a:visited {
color: #000;
}

ul, menu, dir {
list-style-type: none;

アップデート

nginx.conf
upstream unicorn {
  server unix:/tmp/unicorn.myapp.sock fail_timeout=0;
}

server {
  listen 80 default deferred;
  # server_name example.com;
  root /home/michael/apps/myapp/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 4G;
  keepalive_timeout 10;
}

アプリケーション.css

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require_self
 *= require_tree .
 */
4

0 に答える 0