Skip to content
A set of capistrano recipies for working with drupal
Find file
Pull request Compare This branch is 12 commits ahead, 11 commits behind previousnext:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Capistrano Drupal

This gem provides a number of tasks which are useful for deploying Drupal projects.

Credit goes to railsless-deploy for many ideas here.


# gem install drupal-cap


Open your application's Capfile and make it begin like this:

require 'rubygems'
require 'railsless-deploy'
require 'drupal-cap'
load 'sites/default/deploy'

You should then be able to proceed as you would usually, you may want to familiarise yourself with the truncated list of tasks, you can get a full list with:

$ cap -T

Git Ignore

The deployment script expects that sites/default/files and sites/default/settings.php will not be checked into git. Add them to .gitignore in your project.


  • Split out the tasks into indivual files/modules
  • Use drush aliases
  • Support install profiles
  • Support composer

An example sites/default/deploy.rb

set :application, ""
set :repository,  "ssh://"
set :branch,      "master"
set :scm,         :git
set :deploy_via,  :remote_cache

set :deploy_to,   "/var/www/mydrupalproject"

# X, Y, Z have login permissions for this user (public key)
set :user, "serveruser"
set :port, 2222

# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

role :web, ""                          # Your HTTP server, Apache/etc
role :app, ""                          # This may be the same as your `Web` server

set :keep_releases, 5

set :use_sudo, false
set :copy_exclude, [".git"]

# required for cPanel servers (removing writable by group permission)
after 'deploy:create_symlink', 'cpanel:fixchmod'

desc <<-DESC
  Fix file permissions for cPanel
namespace :cpanel do
  task :fixchmod, :roles => [:web, :app] do
    run "chmod g-w #{current_path}/index.php"
    run "chmod g-w #{current_path}/cron.php"
    run "chmod g-w #{latest_release}"

Something went wrong with that request. Please try again.