How to deploy Rails in production mode?

It depends on how you’re running your app. If you’re just using the rails server command, you can do:

rails server -e production

You can also just use RAILS_ENV as you mentioned (but do this in a single line):

RAILS_ENV=production rails server

If you’re more specific about your exact production setup (i.e. are you using Passenger, or Mongrel, or Unicorn, or something else?), we could give you a more specific answer for your situation.

While Passenger defaults to run your app in production mode unless you tell it otherwise, you can make double sure. For Passenger behind Apache, you would add this to your Apache configuration:

RailsEnv production

For Passenger behind Nginx, you would add this to your Nginx configuration:

rails_env production;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)