Rails application deploy environment setup
copy and paste nginx.conf file to /etc/nginx/After Editing server_name and root of application,
copy and paste default_server file to /etc/nginx/site-enable
- First add capistrano, capistrano-bundler, capistrano-rails gam in gemfile.
- Once these are added, run bundle --binstubs and then cap install STAGES=production to generate your capistrano configuration.
require 'capistrano/bundler' require 'capistrano/rails'If you are using rbenv add these lines:
- require 'capistrano/rbenv'
- set :rbenv_type, :user # or :system, depends on your rbenv setup
- set :rbenv_ruby, '2.0.0-p451'
If you are using rvm add these lines:
- require 'capistrano/rvm'
- set :rvm_type, :user
- set :rvm_ruby_version, '2.0.0-p451'
set :application, 'myapp' set :repo_url, 'git@github.com:excid3/myapp.git'open up config/deploy/production.rb file to set the server IP address that we want to deploy to:set :deploy_to, '/home/deploy/myapp'
set :linked_files, %w{config/database.yml config/secrets.yml} set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :deploy do
desc 'Restart application' task :restart do on roles(:app), in: :sequence, wait: 5 do execute :touch, release_path.join('tmp/restart.txt') end end
after :publishing, 'deploy:restart' after :finishing, 'deploy:cleanup' end
set :stage, :production
- Replace 127.0.0.1 with your server's IP address! server '127.0.0.1', user: 'deploy', roles: %w{web app db}