deployment capistrano unicorn nginx rails3

原创文章,转载请注明来源并保留原文链接

How deploy rails3 application using capistrano,unicorn,and nginx.
As we know,Capistrano is a auto-deploy tool kit just like Rake.

First,Let us deploy with unicorn and nginx on the server.
1)install nginx

sudo apt-get install nginx

2)install unicorn

[sudo] gem install unicorn

3)config unicorn under nginx
Find where is your nginx directory. Mine is /etc/nginx.

nginx.conf

conf.d/unicorn.conf

NOTE!!!
# path for static files
root /path/to/your_app/current/public;

# Rails error pages
error_page 500 502 503 504 /500.html;
location = /500.html {
  root /path/to/your_app/current/public;
}

Now,go into your application directory. Copy unicorn.rb into config directory.

unicorn.rb

run:

[sudo] unicorn_rails -c /config/unicorn.rb -D -E production

And than restart your nginx server. Finished!

Next let’s set up capistrano for rails3 application.
4)install capistrano
add capistrano in your Gemfile

gem 'capistrano'

Than

[sudo] bundle install

And

capify .
# This will create Capfile under the root and deploy.rb under /config

6)The last thing is create your own deploy.rb file

deploy.rb

Finally

cap deploy

The End.

Leave a Reply

Your email address will not be published. Required fields are marked *