1

我在使用 Nginx 和 Unicorn 部署 Ruby on Rails 应用程序时遇到了问题。

应用程序启动良好,但资产未加载。任何人都可以帮忙吗?

宝石文件

source 'https://rubygems.org'

gem 'rails', '4.0.0'
gem 'mysql2'

gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'turbolinks'
gem 'hirb'
gem 'jbuilder', '~> 1.2'

gem "rmagick"
gem "carrierwave"
gem 'russian'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

gem 'unicorn'

Nginx 配置文件

server {
    listen 80;
    server_name domain-name.ru;
    return 301 $scheme://domain-name.ru$request_uri;
}

upstream unicorn {
    server unix:/tmp/unicorn.yp.sock fail_timeout=0;
}

server {

    listen 80;
    server_name yellowpump.ru;
    root path_to_app/domain-name.ru/www/public;

    charset utf-8;
    error_page 404 /404.html; 

    location / {
        try_files $uri/index.html $uri.html $uri @unicorn;
        error_page 404              /404.html;
        error_page 422              /422.html;
        error_page 500 502 503 504  /500.html;
        error_page 403              /403.html;
    }

    location @unicorn {
        proxy_pass http://unicorn;
    }

    location ~ ^/assets/ {
            root path_to_app/domain-name.ru/www/public;
            gzip_static on; # to serve pre-gzipped version
            expires 1y;
            add_header Cache-Control public;
            add_header ETag "";
            break;
    }

    #include conf/h5bp.conf;
}

独角兽会议

base_path = "path_to_root_directory_application"

working_directory base_path

pid "#{base_path}/tmp/pids/unicorn.pid"

stderr_path "#{base_path}/unicorn/unicorn.log"
stdout_path "#{base_path}/unicorn/unicorn.log"

listen "/tmp/unicorn.yp.sock"
worker_processes 4
timeout 30

我开始的独角兽bundle exec unicorn -c config/unicorn.rb -d -E production

我尝试rake assets:precompile但出现错误marshal data to short

谁能告诉我,我做错了什么??

4

0 回答 0