Skip to content

Instantly share code, notes, and snippets.

Created Dec 7, 2011
What would you like to do?
Capistrano Drupal(6) Deployment Recipe
# Capistrano recipe for deploying Drupal7 using git and ssh.
# Part of the explanations in the comments taken from:
set :default_environment, {
# This is the $PATH for the deploymant shell. using uberpsace's recent php
# and added ~/bin for drush.
'PATH' => "$HOME/bin/:/package/host/localhost/php-5/bin/:$PATH:"
set :domain , ""
set :user , "vortrieb"
set :application , " Website"
set :repository , ""
# This is where the currentshared and releases folder will be created.
set :deploy_to , "/var/www/virtual/#{user}/"
# delete all but the last n releases.
set :keep_releases , 4
set :use_sudo , false
set :scm , :git
set :branch , "master"
set :scm_verbose , true
# Remote caching will keep a local git repo on the server you’re deploying to
# and simply run a fetch from that rather than an entire clone. This is
# probably the best option as it will only fetch the changes since the last.
# In most cases you want to use this option, otherwise each deploy will do
# a full repository clone every time.
set :deploy_via, :remote_cache
# If you’re using git submodules you must tell cap to fetch them.
set :git_enable_submodules, 1
# we're using private keys, so capistrano should use 'em too.
ssh_options[:forward_agent] = true
# Must be set for the password prompt from git to work
default_run_options[:pty] = true
# we only need one role
role :website, domain, :primary => true
# register the callbacks
after 'deploy:setup' , 'drupal:setup'
after 'deploy:symlink' , 'drupal:symlink'
after 'deploy' , 'drupal:clear_cache'
# override default tasks that wont apply to drupal/php
namespace :deploy do
task :set_permissions do
# noop
task :restart do
# noop
task :start do
# noop
namespace :drupal do
# create shared files-directory
task :setup do
run "mkdir -p #{shared_path}/files"
# symlink shared directories
task :symlink do
run "ln -s #{shared_path}/files #{latest_release}/sites/default/files"
# expect drush to be in $PATH
task :clear_cache do
run "cd #{latest_release} && drush cc all"
# vim: set ts=8 sw=2 tw=79 cc=80 ft=ruby:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment