![]() |
|
|
RAILS_ENV with mod_fcgid and SuEXECGetting Ruby on Rails to behave itself running under FastCGI (as provided by mod_fcgid) and SuEXEC can be challenging. One subtle problem is that Rails expects its environment (production, development, test, etc.) to be specified within a environmental variable called 'RAILS_ENV'. Unfortunately, SuEXEC will not allow that variable to be passed into its environment. The variable can be set directly within the environment.rb file in your application, but that makes moving from development to production difficult and error prone. The solution is to work around the SuEXEC naming restrictions: Inside your environment.rb file: Inside your fcigd configuration (in httpd.conf or one of its conf.d files): If you're using Capistrano, you may also want to put in duplicate variables there to make sure all the sub-scripts are in sync with the environment, since they won't see the variables passed around inside the Apache environment. In your deploy.rb file: Voila, your app will automatically switch to production upon deployment. |