This gem provides two capistrano tasks:
nginx:setup – creates /etc/nginx/sites-available/YOUR_APP and links it to /etc/nginx/sites-enabled/YOUR_APPnginx:reload – invokes /etc/init.d/nginx reload on serverAnd nginx configuration file generator, that will create local copy of default nginx config for customization.
Add this line to your application’s Gemfile:
gem 'capistrano-nginx'
And then execute:
$ bundle
Or install it yourself as:
$ gem install capistrano-nginx
Add this to your config/deploy.rb file:
require 'capistrano/nginx/tasks'
Make sure, following variables are defined in your config/deploy.rb:
application - application nameserver_name - your application’s server_name in nginx (e.g. example.com)deploy_to - deployment pathapp_port - application port (optional)Launch new tasks:
$ cap nginx:setup
$ cap nginx:reload
Or you can add hook to call this tasks after deploy:setup. Add to your config/deploy.rb:
after "deploy:setup", "nginx:setup", "nginx:reload"
If you want to customize nginx configuration, just generate local nginx config before running nginx:setup:
$ rails generate capistrano:nginx:config
And then edit file config/deploy/nginx_conf.erb as you like.
git checkout -b my-new-feature)git commit -am 'Added some feature')git push origin my-new-feature)