Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Setup   
I had a lot of trouble with online recipes not matching the version of Capistrano I had. I settled on Capistrano v2.15.5 since that's what the Blacklight project is using. (capistrano-ext hasn't changed since 2008)
You'll need Ruby, Capistrano, PHP, MySQL, Git, drush, and a server to run the Drupal site. Here's how to setup MacOS.

Install capistrano and capistrano-ext (for the multi-stage feature):

Code Block
gem install capistrano -v 2.15.5
gem install capistrano-ext

...

Set up the local directory

  • Add these empty directories:
    • backup
    • drupal_config
    • private_files
    • public
  • Let capistrano create it's files and directories
    • Code Block
      
      capify .
      
    • (this creates Capfile and config/deploy.rb)
  • featureserver_test_library_cornell_edu
    • .git
    • .gitignore
    • README.txt
    • backup/ - place for backup files
    • drupal_config/ - a place for Drupal make file and module lists
    • private_files/ - point Drupal's private file directory at this directory (later)
    • public/ - put your Drupal site here (later)

Here's what my .gitignore looks like.

In our environment the public directory is a 'fake submodule' containing Drupal core and some standard modules:

Code Block

 git clone --depth 1 git@git.library.cornell.edu:drupal_7_x.git public

Let capistrano create its default files

...

Now the directory looks like this:

...

Code Block

.
├── .git
│   ├── COMMIT_EDITMSG
│   ├── HEAD
│   ├── branches
│   ├── config
│   ├── description
│   ├── hooks
│   ├── index
│   ├── info
│   ├── logs
│   ├── objects
│   └── refs
├── .gitignore
├── Capfile
├── README.txt
├── backup
│   └── README.txt
├── config
│   └── deploy.rb
├── drupal_config
│   └── README.txt
├── private_files
│   └── README.txt
└── public

...

  • deploy.rb

...

  • Change the default deploy.rb to add stages (eg. staging, production) and add a deploy directory containing a file for each stage.

...

  • featureserver_test_library_cornell_edu
    • .git
    • .gitignore
    • Capfile
    • config
      • deploy
        • staging.rb
        • production.rb
      • deploy.rb
    • README.txt
    • backup/ - place for backup files
    • private_files/ - point Drupal's private file directory at this directory (later)
    • public/ - put your Drupal site here (later)

...

  •  Here are some examples

...

...

...

  •  that work for CUL servers.You might as well plan to customize these .rb files to suit your server and site needs, even if you're new to Ruby. You'll need to at least modify the URLs and paths wherever there is a TODO comment.
    Code Block
    
    config
    ├── deploy
    │   ├── production.rb
    │   └── staging.rb
    └── deploy.rb
    

Now might be a good time to add all these new files into git.

Code Block
bash> git add Capfile config/ drupal_config/
bash> git commit Capfile -m 'inital version from capify'
bash> git commit config/ -m 'staging and production deploy instructions'
bash> git commit drupal_config/ -m 'where to put Drupal make file and friends'

The Drupal Site

Next step: build the drupal site inside public/ including an installation profile we can use to build the site on a target machine.

Once you get the Drupal site set up you'll need to push that all into git also.

  • Build a make file and lists of modules in the drupal_config directory

Before the first deploy

Set up the staging/production server directories

...

  • push a tag for this release to git
  • do a backup of the staging db (with the staging site offline)
  • update the staging server's clone of your git repo
  • check out all the stuff from the local git repo to a revision directory on staging
  • change the 'current' symbolic link to point to the public directory inside new revision directory
  • update symbolic links from the revision directory's public/sites/default/files
  • put the site offline
  • update the site's public, private, and temp files paths
  • run update.php
  • revert any features
  • put the site back online

References

http://www.58bits.com/blog/2013/03/23/deploying-drupal-with-capistrano

http://previousnext.com.au/blog/simple-and-powerful-drupal-site-deployment-capistrano

http://www.metaltoad.com/blog/capistrano-drupal-deployments-made-easy-part-1

http://www.zodiacmedia.co.uk/blog/professional-deployment-of-websites-using-capistrano-part-2

https://github.com/capistrano/capistrano/wiki/2.x-Default-Deployment-Behaviour

https://github.com/czettnersandor/drupal-cap

http://www.simonecarletti.com/blog/2009/09/capistrano-file-transfer-actions/