Friday, July 25, 2014

Deploy PHP Application Using Capistrano 2.15

Deployment With Capistrano:

We can also deploy php app using ruby gem capistrano. For this we have to install it first on our system.

gem install capistrano -v 2.15.5
gem install railsless-deploy

After that on any place we have to initialized it. For this use:

capify .


It will create following two files

config/deploy.rb
Capfile

Add in the Capfile

require 'railsless-deploy'
load 'config/deploy'
Now edit the deploy.rb

  1. set :application, "App name"
  2. set :repository, "https://username:password@yourrepository.org/project-repository.git"
  3. set :user, 'shh_username'
  4. set :scm, :git
  5. set :normalize_asset_timestamps, false
  6. set :deploy_to, "/full/path/to/your project"
  7.  
  8. set :deploy_via, :copy
  9. set :use_sudo, false
  10. set :copy_exclude, [".git", ".DS_Store", ".gitignore", ".gitmodules", "Capfile", "config/deploy.rb"]
  11.  
  12. server "server name", :app
  13. namespace :myapp do task :restart_webserver do #Show Start of Task print "Restarting webserver..." # Restart Web Server run "#{sudo} service apache2 restart" end end after "deploy","myapp:restart_webserver"

We can also use deply_via:remote_cache.

Now setup deploy and then execute it.



cap deploy:set
cap deploy

It will create three folders on root
project_root/releases
project_root/shared
project_root/current
 

No comments:

Post a Comment