部署rails生产环境

  • 1、添加Gem
1
2
gem 'unicorn'
gem 'execjs'
  • 2、添加unicorn的配置文件
1
2
3
4
5
6
7
8
9
10
11
12
touch config/unicorn.conf
vi config/unicorn.conf
rails_env = ENV['RAILS_ENV'] || 'production'
user 'root'
worker_processes 2
preload_app true
timeout 30
listen 3009
working_directory "/www/htdocs/weixin_backend"
pid "/www/htdocs/weixin_backend/unicorn.pid"
stderr_path "/www/htdocs/weixin_backend/log/unicorn.stderr.log"
stdout_path "/www/htdocs/weixin_backend/log/unicorn.stdout.log"
  • 3、添加启动脚本
1
unicorn_rails -E production -c config/unicorn.rb -D
  • 4、启动之前需要先执行
1
rake assets/precompile
  • 5、配置nginx
1
2
3
4
location /assets 
{
root /www/htdocs/weixin_backend/public;
}

推荐文章