I'm running the app under Apache2 and Phusion Passenger.
Setting a UNIX shell environment variable in .bashrc, etc., doesn't work because the files are not sourced from Apache.
The way to do this is to set them within your Apache Virtual Host block using the SetEnv directive. For example, here is a vhost block for my app:
<VirtualHost *:80>Then in your application, typically in your config/environment.rb file, you would access this as:
SetEnv FOOBAR "foobar"
Allow from all
my_variable = ENV['FOOBAR']
This works great but ONLY with version 2.2.3 or higher of the Passenger Gem. To see what version you have installed:
$ gem list passengerand to update:
$ sudo gem update passenger
$ sudo passenger-install-apache2-module