Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy Rails in production mode?

How do I put a Rails 3.0 in production mode?

Do I simply just put the following code in config/environment:

RAILS_ENV = 'production'

Is there anything else I need to change?

Thank you.

like image 952
Brian Avatar asked Aug 22 '11 22:08

Brian


People also ask

Where do I put JavaScript code in Rails?

The directory structure for JavaScript has changed to the app/javascript/packs/ folder. In that folder you will find the application. js file, which is just like the application.

How do I run Ruby app on Linux?

Open a terminal window. One way open the terminal window (sometimes called a "shell" or "bash shell") is to select Applications > Accessories > Terminal. Run the command which ruby. If you see a path such as /usr/bin/ruby, Ruby is installed.


2 Answers

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;
like image 145
Dylan Markow Avatar answered Oct 09 '22 05:10

Dylan Markow


This is the answer:

$ RAILS_ENV=production rake db:migrate
like image 37
user917158 Avatar answered Oct 09 '22 05:10

user917158