Skip to content

Single server setup

bruno- edited this page Oct 18, 2014 · 6 revisions

This page describes how to use capistrano-unicorn-nginx plugin to deploy your Rails app on a single server.

Presumably, your stage file config/deploy/production.rb currently contains something like this:

server '123.123.123.123', user: 'deploy', roles: %w{web app db}

0. requirement: passwordless sudo for deployer user

Deployer user on the server should have passwordless sudo enabled. Setting this should be pretty straightforward (google if not sure how).

1. update Capfile

require 'capistrano/unicorn_nginx'

2. specify domain name in config/deploy/production.rb (optional)

Only if you have a domain for your app specify it:

set :nginx_server_name, 'mydomain.com'

If you don't have a domain, you do not have to do anything. nginx_server_name will use the default value - server IP.

3. SSL setup in stage file config/deploy/production.rb (optional - only if you have SSL)

# ignore this if you do not need SSL
set :nginx_use_ssl, true
set :nginx_ssl_cert_local_path, '/path/to/ssl_cert.crt'
set :nginx_ssl_cert_key_local_path, '/path/to/ssl_cert.key'

4. run setup task

In the terminal run:

$ bundle exec cap production setup

Gotchas

  • Make sure the deploy_to path (i.e. /var/www/myapp) exists and has the right privileges on the server.
    Or just install capistrano-safe-deploy-to plugin and don't think about it.
Clone this wiki locally