LoginSignup
0
0

More than 3 years have passed since last update.

PHP サイト でも Capistrano (Ruby Gem)

Last updated at Posted at 2020-03-22

環境

  • Ruby 2.6.5

設定手順

Capistrano 設定ファイルの用意

bundle add capistrano
bundle exec cap install

これで必要なファイルが作成されます。

あとは deploy.rb, config/deploy/* を変更して設定完了です。

ファイルを置けば使えるPHPサイトなら、認証設定程度を記述すればOKです。

設定ファイル例

staging.rb/production.rb
# server configuration
role :web, %w{ec2-user@123.123.123.123}
# file location
set :deploy_to, "/var/www/xxx"
deploy.rb
# application name
set :application, "xxxxxx"
# repository
set :repo_url, "sample@sample.git.jp:/sample.git"

# Default branch is :master
ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp

# revision to be kept
set :keep_releases, 2

デプロイ手順

# config/deploy/staging.rb を使ったデプロイ
bundle exec cap staging deploy
# config/deploy/production.rb を使ったデプロイ
bundle exec cap production deploy

ロールバック手順

cap deploy:rollback

このほかにも cap deploy:rollback:code などがある。

0
0
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
0
0