【问题标题】:Rails Cache Permission ErrorRails 缓存权限错误
【发布时间】:2015-02-21 01:17:44
【问题描述】:

我有一个在 Digital Ocean 上运行并通过 Cloud 66 部署的 Rails 应用程序(Spree Commerce 商店)。

我想通过 SSH 连接到我的服务器,运行 rails 控制台,并调整一些 Spree 配置设置。当我尝试这样做时,出现权限错误:

Errno::EACCES: 权限被拒绝 @ dir_s_mkdir - /var/deploy/my-app/web_head/releases/20150220220517/tmp/cache/29B

根据Spree Developer Guide's page on preferences,这是因为首选项被缓存到内存中以提高性能。问题(我认为)是我的用户没有对 tmp/cache 目录的写入权限,而运行 rails 控制台的是我的用户。

如果我在 $STACK_PATH/tmp/cache 目录上ls -l,我会得到以下信息:

> lrwxrwxrwx 1 nginx nginx 43 Feb 20 22:05
> tmp/cache ->
> /var/deploy/my-app/web_head/shared/cache

我想我需要像 nginx 用户一样授予我的用户对该目录的写入权限。我尝试将自己添加到 nginx 用户组,但这似乎没有任何效果。我该怎么做才能防止出现此权限错误?

【问题讨论】:

  • ls -l /var/deploy/my-app/web_head/releases/20150220220517/tmp/cache 的输出是什么?
  • lrwxrwxrwx 1 nginx nginx$STACK_PATH 是一个引用 /var/deploy/my-app/web_head/current 的变量,它又链接到最新的 /releases 目录。
  • 可能是这个unix.stackexchange.com/a/1315,我用谷歌搜索的是'default permissions linux'

标签: ruby-on-rails spree digital-ocean cloud66


【解决方案1】:

好的,我是根据 Cloud 66 支持论坛上的 this question and answer 弄清楚的。

我将缓存文件夹的组所有者更改为 app_writers,这是我的用户所属的组。 Cloud 66 的方法是使用部署挂钩。这是对我有用的 yml 文件:

production:
    after_rails:
        command: chown nginx:app_writers /var/deploy/my-app/web_head/current/tmp/cache && chmod -R 775 /var/deploy/my-app/web_head/current/tmp/cache
        target: rails
        run_on: all_servers
        sudo: true

【讨论】:

  • 这是正确的!请注意,在 Rails 4.2 上,路径是 .../current/cache 而不是 .../current/tmp/cache。不知道什么时候发生了变化,以及它是 Rails 4+ 的东西还是 Cloud66 的东西。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-28
  • 2011-08-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多