默认文件权限(Passenger,Rails,Ubuntu服务器)

我部署了一个使用页面caching的Rails应用程序,并通过Ubuntu服务器上的Passenger运行。 Railscaching简单地使用Ruby的File.open来编写caching的文件。

不幸的是,这些文件正在使用模式666编写。所有适当的帐户的umask是022.还有什么可以检查,以确定是什么造成这种情况?

提前致谢。

在你的情况下,你会想修改你的Apache httpd.conf文件来改变RailsRuby

 RailsRuby /usr/local/bin/ruby_with_env 

然后用这些内容创build文件/usr/local/bin/ruby_with_env

 #!/bin/bash umask 022 /usr/bin/ruby $* 

然后确保执行chmod 755 /usr/local/bin/ruby_with_env这样封装脚本chmod 755 /usr/local/bin/ruby_with_env执行了,然后告诉Apache重新加载它的configuration。

另外,这当然假设你已经把ruby安装在/usr/bin ,但是如果你在另外一个地方安装ruby,你需要将这行改为/path/to/ruby $*或者更常用的/usr/bin/env ruby $* ,它将在Apache的path中searchruby。

标题为umask for rails用户的讨论提出了一个类似的解决scheme:

 > I'd like to set umask to 002 for the user running the rails processes. > However, passenger ignores the value set in ~/.profile (or set in > environment.rb via File.umask). I would set it in a wrapper script that sets enviroment stuff and then invokes ruby; use this wrapper script as the target of your PassengerRuby/RailsRuby parameter. See this blog post for an example: 

http://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applications-on-oracle/

我们遇到了同样的问题,问题是我们将Passenger作为独立的nginx托pipe进程运行。 我们重新安装了Passenger作为系统范围的Apache模块(在这种情况下是3.0.11版本),不再有caching文件的权限问题。