h2. Deploying Magento Check the "Wiki":https://github.com/augustash/capistrano-ash/wiki for detailed installation instructions. h2. Deploying Drupal example The capistrano/ash/drupal library takes a hash of Drupal multisites in the following format. @set :multisites, {"default" => "mysite.com", "another" => "another.mysite.com"}@ where each key is a folder in your @sites@ directory and each value is the URL of the multisite. If you are not using multisites, just exclude the @:multisites@ variable definition. h3. Capfile
# Capfile
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
# --------------------------------------------
# :application HAS TO BE DEFINED BEFORE
# REQUIRING 'ash/drupal' LIBRARY
# --------------------------------------------
set :application, "bestappever.com"
set :stages, %w(staging production)
# --------------------------------------------
# Define required Gems/libraries
# --------------------------------------------
require 'ash/drupal'
# --------------------------------------------
# Setting defaults
# --------------------------------------------
# IP-address or host's servername
role :app, "bestappever.com"
role :web, "bestappever.com"
role :db, "bestappever.com", :primary => true
# VCS information.
set :repository, "https://svn.example.com/REPO/trunk"
set :scm_username, "SVN_USER"
set :scm_password, proc{Capistrano::CLI.password_prompt("Subversion password for '#{scm_username}':")}
# SSH login credentials
set :user, "SSH_USER"
set :password, proc{Capistrano::CLI.password_prompt("SSH password for '#{user}':")}
# Deploy to file path
set(:deploy_to) { "/var/www/#{application}/#{stage}" }
# Database credentials
set :dbuser, "DB_USER_NAME"
# Define which files or directories you want to exclude from being backed up
set(:backup_exclude) { [ "var/" ] }
# --------------------------------------------
# Drupal Multi-Sites
# --------------------------------------------
# Setting which folder in the sites directory to use
set :multisites, {
'bestapp' => 'bestappever.com',
}
# --------------------------------------------
# Callbacks - Set Before/After Precedence
# --------------------------------------------
before "deploy:update_code", "deploy:setup_backup"
after "deploy:setup_backup", "backup"
h3. config/deploy/staging.rb
# config/deploy/staging.rb
# Database Name
set :dbname, "DB_NAME"
# Backups Path (/var/www/#{application}/staging/backups)
set :backups_path, "#{deploy_to}/backups"
h3. config/deploy/production.rb
# config/deploy/production.rb
# Database Name
set :dbname, "DB_NAME"
# Backups Path (/var/www/#{application}/production/backups)
set :backups_path, "#{deploy_to}/backups"
h2. Deploying Zend or Zend/Doctrine example
h3. Capfile
# Capfile
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
# --------------------------------------------
# :application HAS TO BE DEFINED BEFORE
# REQUIRING 'ash/zend_doctrine' LIBRARY
# --------------------------------------------
set :application, "BEST_APP_EVER"
# --------------------------------------------
# Define required Gems/libraries
# --------------------------------------------
require 'ash/zend_doctrine'
# --------------------------------------------
# Setting defaults
# --------------------------------------------
# IP-address or host's servername
role :app, "bestappever.com"
role :web, "bestappever.com"
role :db, "bestappever.com", :primary => true
# VCS information.
set :repository, "https://svn.example.com/REPO/trunk"
set :scm_username, "SVN_USER"
set :scm_password, proc{Capistrano::CLI.password_prompt("Subversion password for '#{scm_username}':")}
# SSH login credentials
set :user, "SSH_USER"
set :password, proc{Capistrano::CLI.password_prompt("SSH password for '#{user}':")}
# Deploy to file path
set(:deploy_to) { "/var/www/#{application}/#{stage}" }
# Database credentials
set :dbuser, "DB_USER_NAME"
# Define which files or directories you want to exclude from being backed up
set(:backup_exclude) { [ "var/" ] }
# --------------------------------------------
# Calling our Methods
# --------------------------------------------
before "deploy:update_code", "deploy:setup_backup"
after "deploy:setup_backup", "backup"
after "deploy:setup_shared", "app:setup_shared"
after "zend:symlink", "app:symlink"
# --------------------------------------------
# Application Specific Custom Methods
# --------------------------------------------
namespace :app do
desc "Setup shared directories and permissions specific to the application"
task :setup_shared, :roles => :web, :except => { :no_release => true } do
run "mkdir -p #{shared_path}/media"
sudo "chmod -R 777 #{shared_path}/*"
end
desc "Symlink shared directories specific to the application"
task :symlink, :except => { :no_release => true } do
run "ln -nfs #{shared_path}/media #{current_release}/public/media"
end
end
h3. config/deploy/staging.rb
# config/deploy/staging.rb
# Deploy site using Capistrano
#
# Usage:
# cap staging deploy:setup
# cap staging deploy
# Database Name
set :dbname, "DB_NAME"
# Backups Path (/var/www/#{application}/staging/backups)
set :backups_path, "#{deploy_to}/backups"
h3. config/deploy/production.rb
# config/deploy/production.rb
# Deploy site using Capistrano
#
# Usage:
# cap production deploy:setup
# cap production deploy
# Database Name
set :dbname, "DB_NAME"
# Backups Path (/var/www/#{application}/production/backups)
set :backups_path, "#{deploy_to}/backups"
h2. WordPress example
h3. Capfile
# Capfile
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
# --------------------------------------------
# :application HAS TO BE DEFINED BEFORE
# REQUIRING 'ash/wordpress' LIBRARY
# --------------------------------------------
set :application, "WP_EXAMPLE.com"
# --------------------------------------------
# Define required Gems/libraries
# --------------------------------------------
require 'ash/wordpress'
# --------------------------------------------
# Setting defaults
# --------------------------------------------
# IP-address or host's servername
role :app, "wpexample.com"
role :web, "wpexample.com"
role :db, "wpexample.com", :primary => true
# VCS information.
set :repository, "https://svn.example.com/REPO/trunk"
set :scm_username, "SVN_USER"
set :scm_password, proc{Capistrano::CLI.password_prompt("Subversion password for '#{scm_username}':")}
# SSH login credentials
set :user, "SSH_USER"
set :password, proc{Capistrano::CLI.password_prompt("SSH password for '#{user}':")}
# Deploy to file path
set(:deploy_to) { "/home/CLIENT_CODE/#{application}/#{stage}" }
# Database credentials
set :dbuser, "DB_USER"
# Set Excluded directories/files (relative to the application's root path)
set(:backup_exclude) { [ "wp-content/cache" ] }
# --------------------------------------------
# Application Specific Methods
# --------------------------------------------
namespace :app do
desc "Removes any additional unnecessary files or directories after deploy:finalize_update"
task :finalize_update, :except => { :no_release => true } do
logger.debug "Removing additional files"
run "rm -Rf #{latest_release}/htaccess.dist"
end
end
# --------------------------------------------
# Callbacks
# --------------------------------------------
before "deploy:update_code", "deploy:setup_backup"
after "deploy:setup_backup", "backup"
after "deploy:finalize_update", "app:finalize_update"
h3. config/deploy/staging.rb
# config/deploy/staging.rb
# Database Name
set :dbname, "DB_NAME"
# Backups Path (/home/CLIENT_CODE/#{application}/staging/backups)
set :backups_path, "#{deploy_to}/backups"
h3. config/deploy/production.rb
# config/deploy/production.rb
# Database Name
set :dbname, "DB_NAME"
# Backups Path (/home/CLIENT_CODE/#{application}/production/backups)
set :backups_path, "#{deploy_to}/backups"