I deploy a Ruby on Rails
application in ubuntu
with passenger
and nginx
, but it cannot find the css
and js
files in my application.
Here is the error message:
open() "/var/nginx/blog/public/stylesheets/application.css" failed (2: No such file or directory)
In fact, /var/nginx/blog/public/stylesheets/application.css
don't exist actually, my js
files is in /var/nginx/blog/app/assets/javascripts/
, my css
files is in /var/nginx/blog/app/assets/stylesheets
In my nginx.conf
, I write this:
location ~ ^/(assets|images|javascripts|stylesheets|system)/ {
expires max;
add_header Cache-Control public;
}
It seems that this is the place which is wrong! But I comment this, it still cannot find js
and css
. how do I config to get these files?
Maybe you should put your assets in public/
folder. Do you try precompile the assets?
rake assets:precompile
You should to run RAILS_ENV=production bundle exec rake assets:precompile
on remote server where you deploying.
assets:precompile
rake task compressing and minimizing your assets for fast and reliable high-load production usage. Do not need to run this task on your development enviroment.
Would be better if you can show your deploy script. But most of deployment solutions like capistrano automaticaly doing this things right.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.