Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. ThePixelDeveloper revised this gist Oct 29, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # --------------------------------------------
    # General
    # --------------------------------------------
    set :shared_children, %w(config logs) # Shared directories, these directories contain generated content which should not be wiped out during deployments.
    set :shared_children, %w(cache logs) # Shared directories, these directories contain generated content which should not be wiped out during deployments.
    set :application, "domain.com" # Application name
    set :deploy_to, "/var/www/#{application}/#{stage}" # Path where files are deployed to ...

  2. ThePixelDeveloper revised this gist Oct 28, 2009. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -36,11 +36,11 @@
    task :finalize_update, :except => { :no_release => true } do
    # Make sure the log and upload directories do not exist.
    run "rmdir #{latest_release}/application/logs"
    run "rmdir #{latest_release}/upload"
    run "rmdir #{latest_release}/application/cache"

    # Symlink the shared directories to the directories in your application.
    # Symlink the shared directories to the directories in your application.
    run "ln -s #{shared_path}/logs #{latest_release}/application/logs"
    run "ln -s #{shared_path}/upload #{latest_release}/upload"
    run "ln -s #{shared_path}/cache #{latest_release}/application/cache"

    # chmod the files and directories.
    run "find #{shared_path} -type d -exec chmod 0755 {} \\;"
  3. ThePixelDeveloper revised this gist Oct 28, 2009. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -51,8 +51,8 @@
    namespace :web do
    task :disable do
    # When cap deploy:web:disable is run, copy a maintenance.html page from the shared directory
    # to the webroot. You will typically have Apache check for this file and disable access to the
    # site if it exists.
    # to the webroot. You will typically have Apache check for this file and disable access to the
    # site if it exists.
    run "cp #{shared_path}/maintenance.html #{latest_release}"
    run "echo #{stage}"
    end
  4. ThePixelDeveloper revised this gist Oct 28, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -50,7 +50,7 @@

    namespace :web do
    task :disable do
    # When cap deploy:web:disable is run, copy a maintenance.html page from the shared directory
    # When cap deploy:web:disable is run, copy a maintenance.html page from the shared directory
    # to the webroot. You will typically have Apache check for this file and disable access to the
    # site if it exists.
    run "cp #{shared_path}/maintenance.html #{latest_release}"
  5. ThePixelDeveloper revised this gist Oct 28, 2009. 1 changed file with 25 additions and 16 deletions.
    41 changes: 25 additions & 16 deletions PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -1,50 +1,58 @@
    # --------------------------------------------
    # General
    # --------------------------------------------
    set :shared_children, %w(config logs) # Shared directories, these directories contain generated content which should not be wiped out during deployments.
    set :application, "domain.com" # Application name
    set :deploy_to, "/var/www/#{application}/#{stage}" # Path where files are deployed to ...

    # --------------------------------------------
    # Server
    # --------------------------------------------
    # Commands on the server are run as the following user :
    set :runner, "website"
    set :user, "website"
    set :use_sudo, false # sudo isn't required for my deployment.

    # --------------------------------------------
    # Repository
    # --------------------------------------------
    set :scm, :bzr # I am using bazaar, so I specify it here
    set :deploy_via, :export # This will use bzr export as the method of obtaining the code from the repository.
    set :repository, "/home/user/repositories/domain.com" # This is the path to the code repository on the server, remember when you pushed the code up to the server?
    set :repository, "/home/user/repositories/domain.com" # This is the path to the repository on the server, we pushed the code here earlier.

    role :web, "#{application}"

    # --------------------------------------------
    # SSH
    # --------------------------------------------
    ssh_options[:keys] = %w(/home/user/.ssh/private_key) # SSH key
    ssh_options[:port] = 22

    # --------------------------------------------
    # Overloaded Methods.
    # --------------------------------------------
    namespace :deploy do

    desc <<-DESC
    [internal] Touches up the released code. This is called by update_code
    after the basic deploy finishes. It assumes a Rails project was deployed,
    so if you are deploying something else, you may want to override this
    task with your own environment's requirements
    DESC
    task :finalize_update, :except => { :no_release => true } do
    # link log and upload directories
    task :finalize_update, :except => { :no_release => true } do
    # Make sure the log and upload directories do not exist.
    run "rmdir #{latest_release}/application/logs"
    run "rmdir #{latest_release}/upload"

    # Symlink the shared directories to the directories in your application.
    run "ln -s #{shared_path}/logs #{latest_release}/application/logs"
    run "ln -s #{shared_path}/upload #{latest_release}/upload"

    # copy configuration files
    run "cp -rf #{shared_path}/config/ #{latest_release}/application/"

    # copy index.php
    run "cp -f #{shared_path}/index.php #{latest_release}/index.php"

    # chmod directories and files
    # chmod the files and directories.
    run "find #{shared_path} -type d -exec chmod 0755 {} \\;"
    run "find #{latest_release} -type d -exec chmod 0755 {} \\;"
    run "find #{latest_release} -type f -exec chmod 644 {} \\;"
    end

    namespace :web do
    task :disable do
    # When cap deploy:web:disable is run, copy a maintenance.html page from the shared directory
    # to the webroot. You will typically have Apache check for this file and disable access to the
    # site if it exists.
    run "cp #{shared_path}/maintenance.html #{latest_release}"
    run "echo #{stage}"
    end
    @@ -54,5 +62,6 @@
    end
    end

    # Hook the web disable and disable events into the deployment.
    after "deploy:update_code", "deploy:web:disable"
    after "deploy:symlink", "deploy:web:enable"
  6. ThePixelDeveloper revised this gist Oct 28, 2009. 1 changed file with 35 additions and 35 deletions.
    70 changes: 35 additions & 35 deletions PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    set :application, "domain.com" # Application name
    set :deploy_to, "/var/www/#{application}/#{stage}" # Path where files are deployed to ...

    # Commands on the server are run as the following user :
    # Commands on the server are run as the following user :
    set :runner, "website"
    set :user, "website"
    set :use_sudo, false # sudo isn't required for my deployment.
    @@ -18,40 +18,40 @@

    namespace :deploy do

    desc <<-DESC
    [internal] Touches up the released code. This is called by update_code
    after the basic deploy finishes. It assumes a Rails project was deployed,
    so if you are deploying something else, you may want to override this
    task with your own environment's requirements
    DESC
    task :finalize_update, :except => { :no_release => true } do
    # link log and upload directories
    run "rmdir #{latest_release}/application/logs"
    run "rmdir #{latest_release}/upload"
    run "ln -s #{shared_path}/logs #{latest_release}/application/logs"
    run "ln -s #{shared_path}/upload #{latest_release}/upload"

    # copy configuration files
    run "cp -rf #{shared_path}/config/ #{latest_release}/application/"
    # copy index.php
    run "cp -f #{shared_path}/index.php #{latest_release}/index.php"

    # chmod directories and files
    run "find #{shared_path} -type d -exec chmod 0755 {} \\;"
    run "find #{latest_release} -type d -exec chmod 0755 {} \\;"
    run "find #{latest_release} -type f -exec chmod 644 {} \\;"
    end

    namespace :web do
    task :disable do
    run "cp #{shared_path}/maintenance.html #{latest_release}"
    run "echo #{stage}"
    end
    task :enable do
    run "rm -f #{latest_release}/maintenance.html"
    end
    end
    desc <<-DESC
    [internal] Touches up the released code. This is called by update_code
    after the basic deploy finishes. It assumes a Rails project was deployed,
    so if you are deploying something else, you may want to override this
    task with your own environment's requirements
    DESC
    task :finalize_update, :except => { :no_release => true } do
    # link log and upload directories
    run "rmdir #{latest_release}/application/logs"
    run "rmdir #{latest_release}/upload"
    run "ln -s #{shared_path}/logs #{latest_release}/application/logs"
    run "ln -s #{shared_path}/upload #{latest_release}/upload"

    # copy configuration files
    run "cp -rf #{shared_path}/config/ #{latest_release}/application/"

    # copy index.php
    run "cp -f #{shared_path}/index.php #{latest_release}/index.php"

    # chmod directories and files
    run "find #{shared_path} -type d -exec chmod 0755 {} \\;"
    run "find #{latest_release} -type d -exec chmod 0755 {} \\;"
    run "find #{latest_release} -type f -exec chmod 644 {} \\;"
    end

    namespace :web do
    task :disable do
    run "cp #{shared_path}/maintenance.html #{latest_release}"
    run "echo #{stage}"
    end
    task :enable do
    run "rm -f #{latest_release}/maintenance.html"
    end
    end
    end

    after "deploy:update_code", "deploy:web:disable"
  7. ThePixelDeveloper revised this gist Oct 28, 2009. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -3,13 +3,13 @@
    set :deploy_to, "/var/www/#{application}/#{stage}" # Path where files are deployed to ...

    # Commands on the server are run as the following user :
    set :runner, "website"
    set :user, "website"
    set :use_sudo, false # sudo isn't required for my deployment.
    set :runner, "website"
    set :user, "website"
    set :use_sudo, false # sudo isn't required for my deployment.

    set :scm, :bzr # I am using bazaar, so I specify it here
    set :deploy_via, :export # This will use bzr export as the method of obtaining the code from the repository.
    set :repository, "/home/user/repositories/domain.com" # This is the path to the code repository on the server, remember when you pushed the code up to the server?
    set :scm, :bzr # I am using bazaar, so I specify it here
    set :deploy_via, :export # This will use bzr export as the method of obtaining the code from the repository.
    set :repository, "/home/user/repositories/domain.com" # This is the path to the code repository on the server, remember when you pushed the code up to the server?

    role :web, "#{application}"

  8. ThePixelDeveloper revised this gist Oct 28, 2009. 1 changed file with 5 additions and 13 deletions.
    18 changes: 5 additions & 13 deletions PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,19 @@
    # Shared directories, these directories contain generated content which should not be wiped out during deployments.
    set :shared_children, %w(config logs)

    # Application name
    set :application, "domain.com"

    # Path where files are deployed to ...
    set :deploy_to, "/var/www/#{application}/#{stage}"
    set :shared_children, %w(config logs) # Shared directories, these directories contain generated content which should not be wiped out during deployments.
    set :application, "domain.com" # Application name
    set :deploy_to, "/var/www/#{application}/#{stage}" # Path where files are deployed to ...

    # Commands on the server are run as the following user :
    set :runner, "website"
    set :user, "website"

    # Sudo isn
    set :use_sudo, false
    set :use_sudo, false # sudo isn't required for my deployment.

    set :scm, :bzr # I am using bazaar, so I specify it here
    set :deploy_via, :export # This will use bzr export as the method of obtaining the code from the repository.
    set :repository, "/home/user/repositories/domain.com" # This is the path to the code repository on the server, remember when you pushed the code up to the server?

    role :web, "#{application}"


    ssh_options[:keys] = %w(/home/mathew/.ssh/private_key)
    ssh_options[:keys] = %w(/home/user/.ssh/private_key) # SSH key
    ssh_options[:port] = 22

    namespace :deploy do
  9. ThePixelDeveloper revised this gist Oct 28, 2009. 1 changed file with 6 additions and 12 deletions.
    18 changes: 6 additions & 12 deletions PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Shared directories, these are directories containing generated content which should not be wiped out during deployments.
    # Shared directories, these directories contain generated content which should not be wiped out during deployments.
    set :shared_children, %w(config logs)

    # Application name
    @@ -14,19 +14,13 @@
    # Sudo isn
    set :use_sudo, false

    # I am using bazaar, so I specify it here
    set :scm, :bzr
    set :deploy_via, :export
    set :scm, :bzr # I am using bazaar, so I specify it here
    set :deploy_via, :export # This will use bzr export as the method of obtaining the code from the repository.
    set :repository, "/home/user/repositories/domain.com" # This is the path to the code repository on the server, remember when you pushed the code up to the server?

    # This is the path to the code repository on the server, remember when you pushed the code up to the server?
    set :repository, "/var/www/repositories/website.com/"
    # ----------------------------------------------------------------------------
    # Role settings
    # ----------------------------------------------------------------------------
    role :web, "#{application}"
    # ----------------------------------------------------------------------------
    # SSH settings
    # ----------------------------------------------------------------------------


    ssh_options[:keys] = %w(/home/mathew/.ssh/private_key)
    ssh_options[:port] = 22

  10. ThePixelDeveloper revised this gist Oct 28, 2009. 1 changed file with 16 additions and 21 deletions.
    37 changes: 16 additions & 21 deletions PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -1,30 +1,25 @@
    # This requires the capistrano-ext and railsless-deploy gems
    #
    # Github are disabling their gems service after 1 year starting from 2009, refer to
    # http://github.com/leehambley/railsless-deploy for any updates concerning this.
    #
    # gem sources -a http://gems.github.com/
    # gem install capistrano-ext
    # gem install leehambley-railsless-deploy
    # Shared directories, these are directories containing generated content which should not be wiped out during deployments.
    set :shared_children, %w(config logs)

    # ----------------------------------------------------------------------------
    # Capistrano settings
    # ----------------------------------------------------------------------------
    set :shared_children, %w(config upload logs)
    # ----------------------------------------------------------------------------
    # Application settings
    # ----------------------------------------------------------------------------
    set :application, "website.com"
    set :deploy_to, "/var/www/website.com/#{stage}"
    # Application name
    set :application, "domain.com"

    # Path where files are deployed to ...
    set :deploy_to, "/var/www/#{application}/#{stage}"

    # Commands on the server are run as the following user :
    set :runner, "website"
    set :user, "website"

    # Sudo isn
    set :use_sudo, false
    # ----------------------------------------------------------------------------
    # Repository settings
    # ----------------------------------------------------------------------------

    # I am using bazaar, so I specify it here
    set :scm, :bzr
    set :deploy_via, :export
    set :repository, "/var/www/repositories/website.com/" # This can be a github repository, etc ... mine is local.

    # This is the path to the code repository on the server, remember when you pushed the code up to the server?
    set :repository, "/var/www/repositories/website.com/"
    # ----------------------------------------------------------------------------
    # Role settings
    # ----------------------------------------------------------------------------
  11. ThePixelDeveloper revised this gist Oct 15, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    # http://github.com/leehambley/railsless-deploy for any updates concerning this.
    #
    # gem sources -a http://gems.github.com/
    # sudo gem install capistrano-ext
    # gem install capistrano-ext
    # gem install leehambley-railsless-deploy

    # ----------------------------------------------------------------------------
  12. ThePixelDeveloper revised this gist Oct 15, 2009. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,12 @@
    # This requires the capistrano-ext and railsless-deploy gems
    #
    # Github are disabling their gems service after 1 year starting from 2009, refer to
    # http://github.com/leehambley/railsless-deploy for any updates concerning this.
    #
    # gem sources -a http://gems.github.com/
    # sudo gem install capistrano-ext
    # gem install leehambley-railsless-deploy

    # ----------------------------------------------------------------------------
    # Capistrano settings
    # ----------------------------------------------------------------------------
  13. ThePixelDeveloper created this gist Oct 15, 2009.
    68 changes: 68 additions & 0 deletions PHP Capistrano Recipe.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    # ----------------------------------------------------------------------------
    # Capistrano settings
    # ----------------------------------------------------------------------------
    set :shared_children, %w(config upload logs)
    # ----------------------------------------------------------------------------
    # Application settings
    # ----------------------------------------------------------------------------
    set :application, "website.com"
    set :deploy_to, "/var/www/website.com/#{stage}"
    set :runner, "website"
    set :user, "website"
    set :use_sudo, false
    # ----------------------------------------------------------------------------
    # Repository settings
    # ----------------------------------------------------------------------------
    set :scm, :bzr
    set :deploy_via, :export
    set :repository, "/var/www/repositories/website.com/" # This can be a github repository, etc ... mine is local.
    # ----------------------------------------------------------------------------
    # Role settings
    # ----------------------------------------------------------------------------
    role :web, "#{application}"
    # ----------------------------------------------------------------------------
    # SSH settings
    # ----------------------------------------------------------------------------
    ssh_options[:keys] = %w(/home/mathew/.ssh/private_key)
    ssh_options[:port] = 22

    namespace :deploy do

    desc <<-DESC
    [internal] Touches up the released code. This is called by update_code
    after the basic deploy finishes. It assumes a Rails project was deployed,
    so if you are deploying something else, you may want to override this
    task with your own environment's requirements
    DESC
    task :finalize_update, :except => { :no_release => true } do
    # link log and upload directories
    run "rmdir #{latest_release}/application/logs"
    run "rmdir #{latest_release}/upload"
    run "ln -s #{shared_path}/logs #{latest_release}/application/logs"
    run "ln -s #{shared_path}/upload #{latest_release}/upload"

    # copy configuration files
    run "cp -rf #{shared_path}/config/ #{latest_release}/application/"

    # copy index.php
    run "cp -f #{shared_path}/index.php #{latest_release}/index.php"

    # chmod directories and files
    run "find #{shared_path} -type d -exec chmod 0755 {} \\;"
    run "find #{latest_release} -type d -exec chmod 0755 {} \\;"
    run "find #{latest_release} -type f -exec chmod 644 {} \\;"
    end

    namespace :web do
    task :disable do
    run "cp #{shared_path}/maintenance.html #{latest_release}"
    run "echo #{stage}"
    end
    task :enable do
    run "rm -f #{latest_release}/maintenance.html"
    end
    end
    end

    after "deploy:update_code", "deploy:web:disable"
    after "deploy:symlink", "deploy:web:enable"