Apache won't server static assets for rails app Apache won't server static assets for rails app apache apache

Apache won't server static assets for rails app


I used,

RAILS_ENV=production bundle exec rake assets:precompile

To make it all work right, I added this to config/application.rb...

module MyApp  class Application < Rails::Application..    config.assets.precompile += ['custom.css']        config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)..  endend

(I had created custom.css.scss. But Rails did not recognize .scss, as you see above.) I assume that all your assets are appearing in public/assets folder after precompile. I don't understand what you are doing with LocationMatch, pardon my ignorance. Further more, I did not use port 80. I used 8000. Not sure if that makes a difference.

Also, there's a setting in config/environments/production.rb,

# Disable Rails's static asset server (Apache or nginx will already do this).config.serve_static_assets = false


This is directly from the Rails Asset-pipeline documentation regarding the Apache server:

http://guides.rubyonrails.org/asset_pipeline.html

4.1.1 Far-future Expires Header

Precompiled assets exist on the file system and are served directly by your web server. They do not have far-future headers by default, so to get the benefit of fingerprinting you'll have to update your server configuration to add those headers.

For Apache:

# The Expires* directives requires the Apache module# `mod_expires` to be enabled.<Location /assets/>  # Use of ETag is discouraged when Last-Modified is present  Header unset ETag  FileETag None  # RFC says only cache for 1 year  ExpiresActive On  ExpiresDefault "access plus 1 year"</Location>