In your case you'll want to modify your Apache httpd.conf file to change RailsRuby
to:
RailsRuby /usr/local/bin/ruby_with_env
And then create the file /usr/local/bin/ruby_with_env
with these contents:
#!/bin/bash
umask 022
/usr/bin/ruby $*
Then make sure to do chmod 755 /usr/local/bin/ruby_with_env
so the wrapper script is executable and then tell Apache to reload its configuration.
Also, this of course presumes you have ruby installed in /usr/bin
, but if you have it in another location you'll want to change the line to either /path/to/ruby $*
or the more general /usr/bin/env ruby $*
which will search in Apache's path for ruby.
The discussion entitled Setting umask for rails user suggested a similar solution:
> 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/