-
Notifications
You must be signed in to change notification settings - Fork 12
Drupal Shared Hosting Example
Josh J. edited this page Jan 3, 2014
·
6 revisions
This example is very similar to the Drupal Private Server Example except for two changes:
- use the
ash/drupal_shared_hosting
library:require 'ash/drupal_shared_hosting'
- change the
deploy_to
path to the user's directory:set(:deploy_to) { "/home/#{user}/domains/#{application}/code/#{stage}" }
These examples are useful if your project will be hosted on an AAI shared-hosting server. In the root directory of your project, run the following commands:
capify .
rm -Rf config/deploy.rb; mkdir -p config/deploy
touch config/deploy/staging.rb config/deploy/production.rb
After you have edited your Capfile
and <environment>.rb
files, you will need to run the following command only once:
cap <environment> deploy:setup
cap <environment> deploy:check
Edit your Capfile
to look similar to this (replace any reference to example domains or anything in <CAPS>
with valid params):
# Capfile
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
# --------------------------------------------
# :application HAS TO BE DEFINED BEFORE
# REQUIRING 'ash/drupal'
# --------------------------------------------
set :application, "domain.com"
# --------------------------------------------
# Define required Gems/libraries
# --------------------------------------------
require 'ash/drupal_shared_hosting'
# --------------------------------------------
# Server Variables/Defaults
#
# Alternative Server(s) Configuration:
# role :web, "domain.com" # can also use IP-address or host's servername
# role :db, "domain.com" # can also use IP-address or host's servername
# --------------------------------------------
server "domain.com", :web, :db
set :user, "augash"
set(:deploy_to) { "/home/#{user}/domains/#{application}/code/#{stage}" }
# --------------------------------------------
# Git/SVN Variables
#
# Example SVN configuration:
# set :repository, "https://svn.augustash.com/<PATH/TO/REPO>/trunk"
# set :scm_username, "<SVN_USER>"
#
# Example Git configuration:
# set :repository, "[email protected]:augustash/<REPO_NAME>.git"
# set :scm, "git"
# #set :branch, "master" # define which branch
# # should be used for deployments
# --------------------------------------------
set :repository, "[email protected]:augustash/<REPO_NAME>.git"
set :scm, "git"
# uncomment the line below if your project uses submodules (updates submodules)
#set :git_enable_submodules, 1
# --------------------------------------------
# Database/Backup Variables
# --------------------------------------------
# Database credentials will be defined in the
# settings.production.php or settings.staging.php
# files, which drush will use when doing database
# dumps
set :keep_backups, 3 # only keep 3 backups (default is 10)
# Set Excluded directories/files (relative to the application's root path)
set(:backup_exclude) { [ "var/", "tmp/" ] }
# --------------------------------------------
# Compile Sass stylesheets and upload to servers
#
# ONLY RUNS IF YOU HAVE SET :compass_watched_dirs
#
# :compass_watched_dirs can either be a string or an array
#
# Example:
# # Use the array syntax if you compass watch several directories:
# set :compass_watched_dirs, ["sites/all/themes/ash", "sites/all/themes/my_custom_theme]
# # Use the string syntax if you only compass watch one directory:
# set :compass_watched_dirs, "sites/all/themes/ash"
#
# If you name your public stylesheets directory something
# other than "stylesheets" than you can specify the name of
# the directory with the :stylesheets_dir_name variable
#
# Examples (both assume your compiled stylesheets exist within your :compass_watched_dirs):
# # If your Sass compiles to your assets/css directory (i.e., `sites/all/themes/ash/assets/css`):
# set :stylesheets_dir_name, "assets/css"
# # If your Sass compiles to a separate directory (i.e., `sites/all/themes/ash/styles`):
# set :stylesheets_dir_name, "styles"
# --------------------------------------------
set :skip_compass_compile, false # change to true if you want to skip all compass-related tasks
set :compass_watched_dirs, "sites/all/themes/ash"
# --------------------------------------------
# Callbacks - Set Before/After Precedence
# --------------------------------------------
before "deploy:update_code", "backup"
Edit your config/deploy/production.rb
file to look similar to this:
# Deploy Drupal site using Capistrano
#
# Usage:
# cap production deploy:setup
# cap production deploy
# --------------------------------------------
# Server Variables (Overridden)
#
# If your production site is located on a different
# or multiple servers consider using this syntax:
#
# role :web, "www2.domain.com"
# role :web, "www3.domain.com"
# role :db, "master.domain.com", :primary => true
# role :db, "slave1.domain.com"
# role :db, "slave2.domain.com"
# --------------------------------------------
#server "anotherdomain.com", :web, :db
# --------------------------------------------
# Git/git-flow configuration
#
# if you are using Git or the git-flow workflow
# you should specify the :branch your environment
# deploys from.
#
# For example:
# + the staging environment should use the `develop` branch
# + the production environment should use the `master` branch
# --------------------------------------------
set :branch, "master"
# --------------------------------------------
# Multisites
# --------------------------------------------
# Setting which folder in the sites directory to use
# change's the name of your local site folder to the
# fully qualified domain name (URL) of the live site,
# so if you want the 'www' included in the url use
# this example:
# set :multisites, {
# 'bestappever.local' => 'www.bestappever.com'
# }
set :multisites, {
'bestappever.local' => 'www.bestappever.com',
}
Edit your config/deploy/staging.rb
file to look similar to this:
# Deploy Drupal site using Capistrano
#
# Usage:
# cap staging deploy:setup
# cap staging deploy
# --------------------------------------------
# Git/git-flow configuration
#
# if you are using Git or the git-flow workflow
# you should specify the :branch your environment
# deploys from.
#
# For example:
# + the staging environment should use the `develop` branch
# + the production environment should use the `master` branch
# --------------------------------------------
set :branch, "develop"
# --------------------------------------------
# Multisites
# --------------------------------------------
# Setting which folder in the sites directory to use
# change's the name of your local site folder to the
# fully qualified domain name (URL) of the live site,
# so if you want the 'www' included in the url use
# this example:
# set :multisites, {
# 'bestappever.local' => 'www.bestappever.com'
# }
set :multisites, {
'bestappever.local' => 'staging.bestappever.com',
}