Capistrano recipe for static/php sites


/ Published in: Other
Save to your folder(s)

This snippet is made for textmate (or e editor ?)


Copy this code and paste it in your HTML
  1. set :application, "${1:application}"
  2. set :repository, "${2:svn://}"
  3. set :port, "${3:22}"
  4.  
  5. role :web, "${4:host}" #eg "myapp.com" or "123.456.789.10"
  6. role :app, "${4:host}"
  7. role :db, "${4:host}", :primary => true
  8. set :user, '${5:user}'
  9. # set :use_sudo, false # turn on if you are on a shared host...
  10.  
  11. set :svn_repository_url, '${2:svn://}'
  12. set :checkout, 'export'
  13. set :deploy_via, :export
  14. set :home_path, "${6:home_path}"
  15. set :deploy_to, "#{home_path}/sites/#{application}"
  16. set :shared_dir, "shared"
  17. set :log, "#{shared_dir}/log"
  18. set :etc, "#{shared_dir}/etc"
  19.  
  20. # if you are using apache, here's some stuff to set
  21. set :apache_root, "${7:/etc/apache2}"
  22. set :apache_vhosts_dir, "#{apache_root}/sites-available"
  23.  
  24. namespace :deploy do
  25. task :restart do
  26. # no need to restart the app
  27. end
  28. end
  29.  
  30. namespace :apache do
  31.  
  32. desc 'Setup the vhost and enable the site'
  33. task :setup do
  34. vhost = <<-HOST
  35. <VirtualHost *:80>
  36. ServerName ${8:site_name}
  37. ServerAlias www.${8:site_name}
  38.  
  39. DocumentRoot #{deploy_to}/current/public
  40. </VirtualHost>
  41. HOST
  42.  
  43. put vhost, "#{home_path}/#{application}.tmp"
  44. sudo "mv #{home_path}/#{application}.tmp #{apache_vhosts_dir}/#{application}"
  45.  
  46. enable_site
  47. end
  48.  
  49. desc 'Enables the site'
  50. task :enable_site do
  51. sudo "a2ensite #{application}"
  52. reload
  53. end
  54.  
  55. desc 'Reloads apache'
  56. task :reload do
  57. sudo "${9:/etc/init.d/apache2} reload"
  58. end
  59.  
  60. desc 'Restarts apache gracefully'
  61. task :restart do
  62. sudo "apache2ctl graceful"
  63. end
  64.  
  65. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.