Capistrano::nginx
Nginx support for Capistrano 3.x
Installation
Add this line to your application's Gemfile:
gem 'capistrano', '~> 3.0.0'
gem 'capistrano-nginx', '~> 1.0.0'
And then execute:
$ bundle
Or install it yourself as:
$ gem install capistrano-nginx
Usage
Require in Capfile
:
require 'capistrano/nginx'
Launch new tasks:
$ cap production nginx:setup
$ cap production nginx:reload
If you want to customize the nginx configuration, you can use the Rails generator to create a local copy of the config template:
$ rails generate capistrano:nginx:config
And then edit config/deploy/nginx_conf.erb
as you like.
Configurable options, shown here with defaults:
set :nginx_path, '/etc/nginx' # directory containing sites-available and sites-enabled
set :nginx_template, 'config/deploy/nginx_conf.erb' # configuration template
set :nginx_server_name, 'example.com' # optional, defaults to :application
set :nginx_upstream, 'example-app' # optional, defaults to :application
set :nginx_listen, 80 # optional, default is not set
set :nginx_roles, :all
Tasks
This gem provides the following Capistrano tasks:
-
nginx:setup
creates/etc/nginx/sites-available/APPLICATION.conf
and links it to/etc/nginx/sites-enabled/APPLICATION.conf
-
nginx:stop
invokesservice nginx stop
on server -
nginx:start
invokesservice nginx start
on server -
nginx:restart
invokesservice nginx restart
on server -
nginx:reload
invokesservice nginx reload
on server -
nginx:force-reload
invokesservice nginx force-reload
on server -
nginx:enable_site
creates symlink in sites-enabled directory -
nginx:disable_site
removes symlink from sites-enabled directory
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request