Forum: Ruby on Rails Trouble putting Rails App into Production with apache2

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
1f059cdfd8b92cff931fa2bbfc12a254?d=identicon&s=25 Sean Lerner (Guest)
on 2007-03-26 17:47
(Received via mailing list)

I am trying to put a rails app I development into production. When I
alter my apache config like so:

SetEnv RAILS_ENV production
(used to be SetEnv RAILS_ENV development)

and reload apache, the site still stays in development mode. I do the
following on my homepage to check what environment I'm using:
<%= RAILS_ENV %>

However, if I add this line to my environment.rb:
ENV['RAILS_ENV'] ||= 'production'

The application successfully switches into production mode.

I do have complete control over my server, so I'm trying to "properly"
put the application in production mode, vs. editing the environment.rb

Any suggestions? Let me know if posting more code / commands would be


70225136eacd3d870f64e03bff678655?d=identicon&s=25 Russell Norris (Guest)
on 2007-03-27 19:06
(Received via mailing list)
What does

SetEnv ENV['RAILS_ENV'] production

get you? I noticed this weekend that Apache2 seems to define ENV in some
kind of weird way. If it at all does. ENV == {} in environment.rb for
I'm curious what the deal is.

1f059cdfd8b92cff931fa2bbfc12a254?d=identicon&s=25 Sean Lerner (Guest)
on 2007-03-28 21:25
(Received via mailing list)
Hi Russell,

I tried as you suggested, but it doesn't work. I found this though:

which states

"SetEnv happens on a per-request basis, but your Rails process starts
in the
context of Apache not that of a request."

and that statement leads me to believe that it doesn't matter what I
have configured in my site-specific configuration.

Where's the right spot to configure for a Rails/Apache2/fcgi setup to
switch from development to production?


5030981121b21bed8aee074f68bd5074?d=identicon&s=25 Russell Norris (Guest)
on 2007-03-28 22:12
(Received via mailing list)
Anyone? This is puzzling me too.

C25bf61976ed22c79eaea2a6f5c0968d?d=identicon&s=25 CRAZ8 (Guest)
on 2007-03-29 05:12
(Received via mailing list)
If you are using Apache2 to proxy to Mongrel, then the Mongrel
processes need to be running in Rails production mode, and nothing you
do in Apache config will help.

  mongrel_rails -e production -p <port> ...
5030981121b21bed8aee074f68bd5074?d=identicon&s=25 Russell Norris (Guest)
on 2007-03-29 18:44
(Received via mailing list)
What if we're not using Mongrel?

59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2007-03-29 19:16
(Received via mailing list)
On Mar 29, 2007, at 9:41 AM, Russell Norris wrote:

> What if we're not using Mongrel?

Perhaps you should be? :-)

Try setting the environement variable:


Before starting up your Rails instance and that should do the trick.

-- Tom Mornini, CTO
-- Engine Yard, Ruby on Rails Hosting
-- Reliability, Ease of Use, Scalability
-- (866) 518-YARD (9273)
5030981121b21bed8aee074f68bd5074?d=identicon&s=25 Russell Norris (Guest)
on 2007-03-29 19:19
(Received via mailing list)
Oh, I'm sure I should be but my budget has me on shared hosting at the
moment and last time I looked Mongrel and shared hosting didn't want to
well together. I do run Mongrel on my desktop to develop but even here
I use Apache[2] I don't mongrelize because that's not what the end host

C25bf61976ed22c79eaea2a6f5c0968d?d=identicon&s=25 CRAZ8 (Guest)
on 2007-03-30 08:10
(Received via mailing list)
Are you on Dreamhost?  I've had to add this to the top of my
dispatch.fcgi files for Rails apps on Dreamhost:

  ENV['RAILS_ENV'] = 'production'

I also have a cron that hits the site every 5 minutes to keep it in
5030981121b21bed8aee074f68bd5074?d=identicon&s=25 Russell Norris (Guest)
on 2007-03-30 14:37
(Received via mailing list)
Yeah. I am a DHer. There's also the stopgap line like that you can
in config/environment.rb [which for me was just as easy to uncomment via
Capistrano on deploy] but I was curious about finding the real solution
Apache2's problem. Which, I guess, we _did_ find with that whole request
scope issue. :/

I _did_ discover the perfect reaper action though, for Apache2
you're not using Mongrel]

script/process/reaper -a graceful -d dispatcher.fcgi

Seems like the default reaper task doesn't actually restart the
If you run it multiple times, watch the PID[s] it says it's restarting.
never change because they're never affected. Graceful works nicely
and actually stops the dispatcher. Just a tip. :)

1f059cdfd8b92cff931fa2bbfc12a254?d=identicon&s=25 Sean Lerner (Guest)
on 2007-04-05 16:54
(Received via mailing list)
Hi Folks,

I decided just to live with putting the application into production by
modifying the environment.rb file.

I appreciate all your suggestions. Thanks a lot.

This topic is locked and can not be replied to.