Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple nginx management with capistrano
branch: master
Failed to load latest commit information.
lib version bump
test changed paths
.gitignore added tests and generator; version bump
Gemfile added tests and generator;
LICENSE initial version bump
Rakefile added tests and generator;
capistrano-nginx.gemspec added readme


This gem provides two capistrano tasks:

  • nginx:setup -- creates /etc/nginx/sites-available/YOUR_APP and links it to /etc/nginx/sites-enabled/YOUR_APP
  • nginx:reload -- invokes /etc/init.d/nginx reload on server

And 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 name
  • server_name - your application's server_name in nginx (e.g.
  • deploy_to - deployment path
  • sudo_user - user name with sudo privileges (needed to config/restart nginx)
  • app_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.


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.