Ruby-on-rails How to deploy Rails in production mode?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7154145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to deploy Rails in production mode?
提问by Brian
How do I put a Rails 3.0 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:
Do I simply just put the following code in config/environment:
RAILS_ENV = 'production'
Is there anything else I need to change?
Is there anything else I need to change?
Thank you.
Thank you.
回答by Dylan Markow
It depends on how you're running your app. If you're just using the rails servercommand, you can do:
It depends on how you're running your app. If you're just using the rails servercommand, you can do:
rails server -e production
You can also just use RAILS_ENVas you mentioned (but do this in a single line):
You can also just use RAILS_ENVas 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.
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:
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:
For Passenger behind Nginx, you would add this to your Nginx configuration:
rails_env production;
回答by user917158
This is the answer:
This is the answer:
$ RAILS_ENV=production rake db:migrate

