Craft storage dir as linked in capistrano
I've eventually tracked down this peculiar ERR_EMPTY_RESPONSE to a php error buried deep in my apache logs - zend_mm_heap corrupted. So as it turns out nothing to do with Capistrano (or Craft) at all! This zend_mm_heap error is a php memory error that I seem to have solved by upgrading my version of PHP after unsuccessfully upping my output_buffer as suggested in this stackoverflow thread. It's worth noting that there was nothing in the Craft log about this error, no mention of anything untoward. The Craft\HttpException I found above is, I believe, essentially a '404' error as my site was running in 'offline mode' so requests had to be run through _enforceSystemStatusPermissions.

I did initially have some issues with permissions with Capistrano where my server was setting new files created by craft to 644 www-data:www-data and therefore my user couldn't edit these files, despite being in the www-data group, and so Capistrano was having a hard time removing old releases. I've fixed this by adding a umask 002 to /etc/apache2/envvar.

Now that the zend_mm_heap error seems to be behaving, and my permissions are correct, deploying with Capistrano is working rather well. For future reference, my linked dirs config looks like this:

set :linked_dirs, %w{public/resources craft/config/local craft/storage}


public/resources is my (single) craft asset source, craft/config/local are my server-specific config files as suggested here which is working nicely for me. craft/storage is obviously the craft storage folder that is shared between releases.

In terms of deployment, I think Capistrano (and other tools of a similar ilk) is great. I'm hosting my repository in a private BitBucket account and push new changes onto the master branch. I have two stages set up :production and :staging which deploy to two different vhosts on my server (staging domain is test.domain.com).

My stage configuration looks like this (for staging)

set :stage, :staging

set :deploy_to, "/var/www/domain-test"

# Allow user to define which branch to push, e.g.
# BRANCH=my-new-feature cap staging deploy
set :branch, ENV['BRANCH'] || "staging"


This last line is really helpful if I want to quickly test something on the master branch without having to merge it into the staging branch and push and deploy.

I hope that helps someone who comes across a similar issue. If anyone wants more info about my Capistrano set up, let me know. I highly recommend it as a method of deployment, once you figure out your (inevitable and strange) server errors!