Rails的3.2资产管道薄壁和Apache,没有找到资产 [英] Rails 3.2 Asset Pipeline with Thin and Apache, not finding assets

查看:111
本文介绍了Rails的3.2资产管道薄壁和Apache,没有找到资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是类似于此<一个href=\"http://stackoverflow.com/questions/9162378/rails-3-2-asset-pipeline-with-passenger-endless-errors\">Rails 3.2资产管道与乘客无尽的错误除了当我试图真正去

 &LT;链接HREF =/资产/应用eed7996ee9017637f923133371ab3e92.css媒体=所有的rel =stylesheet属性类型=文/ CSS/&GT;

我得到一个404。这里是我不明白的东西。它是在寻找/资产/,但是当我看到被部署在code,资产只在/公/资产,这实际上是一个符号链接到/ var / WWW / MyApp的/共享/资产。因此,在世界上是什么负责,告诉在寻找/资产将产生正确的结果?应用程序

我使用Rails 3.2.0,红宝石1.9.3-P125,部署到Ubuntu,Apache和薄。

我要澄清:我的资产确实部署到服务器。一切工作完全正常,直到他们需要提供服务,在这种情况下production.log告诉我这是找他们/assets/application-eed7996ee9017637f923133371ab3e92.css,其中404的。

为每个请求我的 thin.log

 缓存:[GET /]错过

production.log

 的ActionController :: RoutingError(无路由匹配[GET]/assets/application-abecf2e096af9ee80697fd49e79a55e7.js):

更新
@Brandan感谢您的帮助。我的资产确实是在 RAILS_ROOT /公/资产。我把这个在我的Apache虚拟主机文件:

 的DocumentRoot的/ var /导轨/ myappname /电流/公RewriteEngine叙述在
XSendFile在
XSendFilePath的/ var /导轨/ myappname #not甚至不确定是否需要这条线&LT; LocationMatch^ /资产/.*$\"& GT;
    头取消设置的ETag
    FileETag无
    ExpiresActive On配置
    ExpiresDefault进入加1年
&LT; / LocationMatch&GT;

我的 RAILS_ROOT /配置/环境/ production.rb 设置:

  config.cache_classes = TRUE
config.consider_all_requests_local = FALSE
config.action_controller.perform_caching =真
config.serve_static_assets = FALSE
config.assets.com preSS = TRUE
config.assets.compile = FALSE
config.assets.digest =真
config.action_dispatch.x_sendfile_header =X-SENDFILE#为Apache


解决方案

我一直在有这个问题了好几天。以为是Capistrano的一个问题,但是还是红宝石版本我pretty确保它是相关的太权限。

我的配置是pretty多和你的一样,虽然我还使用独角兽。

下面是我所做的排序:


  1. 暂时删除下面的部分,因为我觉得与故障排除这是造成问题:

     &LT; LocationMatch/.*$\"& GT ^ /资产;
      头取消设置的ETag
        FileETag无
        ExpiresActive On配置
        ExpiresDefault进入加1年
      &LT; / LocationMatch&GT;


也许得到它的所有工作,然后添加回。我不认为这是问题的原因然而,诊断这样的事情时,最好去除尽可能多的,你可以找到罪魁祸首。


  1. 运行CHOWN -R xxx.xxx(替换为您的应用程序用户或网络用户XXX)的公共目录。当我这样做了,CSS的又出现了。


  2. (我做了什么,但也许不是必要的),你也可能要无盖本地安装。万一有一个与它的问题。这也为我工作。


  3. 完全全军覆没TMP /缓存和公共/ *以防万一。


  4. 重新启动Apache服务器几次。


您可以看到我的conf的依据。 这里

My question is similar to this one Rails 3.2 Asset Pipeline with Passenger Endless Errors except that when I try to actually go to

<link href="/assets/application-eed7996ee9017637f923133371ab3e92.css" media="all" rel="stylesheet" type="text/css" />

I get a 404. Here's the thing I don't understand. It is looking in /assets/, but when I look at the code that was deployed, the assets are only in /public/assets, which is actually a symlink to /var/www/myapp/shared/assets. So what in the world is responsible for telling the app that looking in /assets will produce correct results??

I am using Rails 3.2.0, ruby-1.9.3-p125, deploying to Ubuntu, Apache, and Thin.

I should clarify: My assets are indeed deployed to the server. Everything works perfectly fine until they need to be served, in which case production.log tells me it's looking for them in /assets/application-eed7996ee9017637f923133371ab3e92.css, which 404's.

For every request my thin.log says

cache: [GET /] miss

and production.log says

ActionController::RoutingError (No route matches [GET] "/assets/application-abecf2e096af9ee80697fd49e79a55e7.js"):

UPDATE @Brandan thanks for the help. My assets are indeed in RAILS_ROOT/public/assets. I put this in my Apache vhost file:

DocumentRoot /var/rails/myappname/current/public

RewriteEngine On
XSendFile On
XSendFilePath /var/rails/myappname #not even sure if this line is needed

<LocationMatch "^/assets/.*$">
    Header unset ETag
    FileETag None
    ExpiresActive On
    ExpiresDefault "access plus 1 year"
</LocationMatch>

My RAILS_ROOT/config/environments/production.rb settings:

config.cache_classes = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true
config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache

解决方案

I've been having this problem for days now. Thought it was an issue with capistrano or the ruby version however I'm pretty sure it's permissions related too.

My configuration was pretty much the same as yours although I'm also using Unicorn.

Here's what I did to sort:

  1. Temporarily remove the following section because I think that was causing problems with the troubleshooting:

     <LocationMatch "^/assets/.*$">
      Header unset ETag
        FileETag None
        ExpiresActive On
        ExpiresDefault "access plus 1 year"
      </LocationMatch>
    

Perhaps get it all working and then add it back in. I don't think it's the cause of the problems however, when diagnosing things like this, it's best to remove as much as you can to find the culprit.

  1. Run a chown -R xxx.xxx (replace xxx with your application user or web user) on the public directory. As soon as I did so, the css appeared again.

  2. (What I did but maybe not essential) You might also want to install locally without cap. just in case there's an issue with it. That also worked for me.

  3. Completely wipeout tmp/cache and public/* just in case.

  4. Restart your apache server a couple of times.

You can see a gist of my conf. here

这篇关于Rails的3.2资产管道薄壁和Apache,没有找到资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆