Rails的3.1部署到生产(与Apache和放大器;客运)资产问题 [英] Rails 3.1 Deploy to Production (with Apache & Passenger) Asset Problems

查看:189
本文介绍了Rails的3.1部署到生产(与Apache和放大器;客运)资产问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

3.1的Rails已经改变其处理资产管道的方式,部署到生产时,它造成的问题。

Rails 3.1 has changed the way it handles the asset pipeline and it is causing issues when deploying to production.

我使用的Apache和客运,这似乎很好地工作。

I am using Apache and Passenger, which seem to work fine.

我的生产是这样的设置(现在)。

My production is setup like this (for now).

# congif/environments/production.rb
config.cache_classes = false
config.consider_all_requests_local       = true
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

我运行耙资产:在Ubuntu precompile并启动服务器。和什么都没有。无我的图片加载。

I run rake assets:precompile on Ubuntu and start server. And... nothing. None of my images load.

传说中的盒子我不能在这个网址找一个形​​象。

The legendary 'I can't find an image at this URL' box.

我运行耙资产:在CentOS precompile并启动服务器。而且......权限错误。

I run rake assets:precompile on CentOS and start server. And... permission errors.

*Error Compiling CSS Asset*
Errno::EACCESS: Permission Denied - [app path]/tmp/cache/assets/E95
[path to RVM Ruby]/fileutils.rb:243:in 'mkdir'

我不能让它让步。任何帮助是极大的AP preciated。谢谢!

I can't get it to budge. Any help is greatly appreciated. Thank you!

此解决方案的工作每一次对我来说:

This solution has worked every time for me:

先清理自己的资产

rm -rf public/assets

rake assets:clean RAILS_ENV=production

二,#production.rb变化

Second, in #production.rb change

config.assets.compile = false

config.assets.compile = true

三,运行precompile资产

Third, run to precompile your assets

rake assets:precompile RAILS_ENV=production

四,#production.rb变化

Fourth, in #production.rb change

config.assets.compile = true

返回

config.assets.compile = false

五,通过运行重新启动服务器:

Fifth, restart your server by running:

touch tmp/restart.txt

六,通过运行此命令取消限制对新创建的资产的权限

Sixth, un-restrict permissions on your newly created assets by running this command

搭配chmod -R 777公/资产

chmod -R 777 public/assets

第七,庆祝!!

推荐答案

这是一个简单的权限问题。给服务器/守护进程来创建[APP_PATH] / tmp目录递归文件的权利。

That's a simple permission problem. Give the server/daemon the right to create files in [app_path]/tmp recursively.

假设你的服务器进程与你做到这一点, www数据用户运行:

Assuming your server process runs with the www-data user you do this with:

cd APP_PATH
chmod -R u+w tmp

,如果该目录不属于该用户,你必须改变所有权:

and if the directory does not belong to the user you have to change the ownership:

chown -R www-data tmp

这篇关于Rails的3.1部署到生产(与Apache和放大器;客运)资产问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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