Skip to content

Instantly share code, notes, and snippets.

@pal
Created February 4, 2010 00:52
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save pal/294247 to your computer and use it in GitHub Desktop.
Save pal/294247 to your computer and use it in GitHub Desktop.
Complete Capistrano deployment example for a very simple PHP-site.
# Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
require 'rubygems'
require 'railsless-deploy'
load 'config/deploy'
# Deploy simple PHP-site using Capistrano
# Complete working example for a very simple PHP-site.
#
# Usage:
# cap deploy:setup
# cap deploy
#
# See end for links
# application name
set :application, "capistrano-php-test"
# where is it version controlled?
set :repository, "git@github.com:pal/#{application}.git"
# Using subversion? Try something like this
#set :repository, "http://svn.myhost.com/#{application}/trunk"
#set :scm, :subversion
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `svn`, `mercurial`, `perforce`, `subversion` or `none`
#set :scm_passphrase, "password" # Useful for some setups, but look at http://help.github.com/msysgit-key-setup/
#set :scm_user, "username"
# some like to utilize a cache to speed up checkout/clone
#set :deploy_via, :remote_cache
# If you're stuck with an old version of git on the server you might need this
set :scm_verbose, true
set :ssh_options, {:forward_agent => true} # enable private keys with git
# show password requests on windows (http://weblog.jamisbuck.org/2007/10/14/capistrano-2-1)
default_run_options[:pty] = true
# Select git branch
set :branch, "master"
# where to deploy your uploaded application
set :deploy_to, "/var/www/myhost.com/#{application}"
# point your document root here (but add /current after this path)
set :document_root, "/var/www/myhost.com/httpdocs"
role :app, "myhost.com" # or an IP-address, or your hosts servername
role :web, "myhost.com"
role :db, "myhost.com", :primary => true
# SSH login credentials (or better yet; use passwordless authentication)
set :user, "sshuser"
set :password, "sshpassword"
set :use_sudo, false # in case you do not have root access
# Inspirational URLs:
# http://weblog.jamisbuck.org/search?q=capistrano
# http://www.claytonlz.com/index.php/2008/08/php-deployment-with-capistrano/
# http://paulschreiber.com/blog/2009/03/15/howto-deploy-php-sites-with-capistrano-2/
# http://wiki.dreamhost.com/index.php/Capistrano
# http://www.capify.org/index.php/Getting_Started
# http://www.jonmaddox.com/2006/08/16/automated-php-deployment-with-capistrano/
# http://github.com/leehambley/railsless-deploy
# http://help.github.com/msysgit-key-setup/
# http://help.github.com/capistrano/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment