2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

capistrano2で非railsを配置してみる

Last updated at Posted at 2013-12-05

capistrano 2.15.5使って非railsアプリをサーバ上に配置してみた。
capistrano3でやってみた記事はこちら capistrano3.0で非railsを配置してみる - Qiita [キータ]

試してみた手順

$ bundle init
$ echo "gem 'capistrano', '~> 2.0'" >> Gemfile
$ echo "gem 'capistrano_colors'" >> Gemfile
$ echo "gem 'railsless-deploy'" >> Gemfile
$ bundle install --path vendor/bundle

$ bundle exec capify .
[add] writing './Capfile'
[add] making directory './config'
[add] writing './config/deploy.rb'
[done] capified!

$ tree -L 2
.
├── Capfile
├── Gemfile
├── Gemfile.lock
├── config
│   └── deploy.rb
└── vendor
    └── bundle
  • config/deploy.rbを設定
set :application, "MyTips"
set :repository,  "https://github.com/mechamogera/MyTips"
set :scm, :git
set :keep_releases, 5

set :deploy_to, '/var/www/my_app'                                                                                     

default_run_options[:pty] = true
set :use_sudo, false

# No shared files
set :shared_children, %w()
# for No such file or directory Error
set :normalize_asset_timestamps, false

role :web, "[EC2のDNS名]"
set :user, 'ec2-user'
set :group, 'ec2-user'

before "deploy:setup" do
  run "sudo mkdir -p #{deploy_to}"
  run "sudo chown -R #{user}:#{group} #{deploy_to}"
end

# 念のためafterでも
after "deploy:setup" do
  run "sudo chown -R #{user}:#{group} #{deploy_to}"
end
  • EC2(AmazonLinux)を作成
  • capistrano実行
$ bundle exec cap deploy:setup
$ bundle exec cap deploy
$ bundle exec cap deploy:cleanup
  • EC2確認
$ tree /var/www/my_app/ -L 2
/var/www/my_app/
├── current -> /var/www/my_app/releases/20131205070710
├── releases
│   └── 20131205070710
└── shared
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?