Know to deploy with capistrano, nginx and passenger
Gem file
1
2
3
4
5
gem 'capistrano', '3.11.2'
gem 'capistrano-rails', '1.4.0'
gem 'capistrano-passenger', '0.2.0'
gem 'capistrano-rbenv', '2.1.4 '
# capistrano-rvm
after bundle install you can use cap install command to auto generate follow file:
1
2
3
4
require "capistrano/rails"
require "capistrano/passenger"
require "capistrano/rbenv"
#capistrano-rvm
1
2
3
4
5
6
7
8
9
10
11
# config valid for current version and patch releases of Capistrano
lock "~> 3.14.1"
set :application, "profile"
set :repo_url, "git@github.com:nvt94/profile.git"
set :branch, 'master'
set :deploy_to, '/var/www/profile'
set :use_sudo, true
set :linked_files, %w(config/database.yml config/application.yml)
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
1
server "sample-web-server", user: "deploy", roles: %w{app db web}
This option specifies that the master key used to decrypt credentials should be available on our web server. config.require_master_key = true
1
2
EDITOR="mine" bin/rails credentials:edit
The config/master.key and config/credentials.yml.enc files will be generated.
install nginx install passenger
mod-http-passenger.conf file passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; passenger_ruby /usr/bin/passenger_free_ruby;
site-enabled
1
2
3
4
5
6
7
8
9
server {
listen 80;
server_name devorip.com; #replace with your server ip or domain
# Tell Nginx and Passenger where your app’s ‘public’ directory is
root /var/www/profile/current/public;
# Turn on Passenger
passenger_enabled on;
passenger_ruby /home/deploy/.rbenv/versions/2.6.6/bin/ruby;
}
cap production deploy cap staging deploy
Comments