RSS
14 Aug 2007

Deploying Joomla using Capistrano 2.0

Author: ceefour | Filed under: Beginner, Books, Cool, Enterprise, Indonesia, Praises, Rails, Reviews, Ruby, Tips, Tools, Web 2.0

Who said Capistrano is for Ruby on Rails only?

 Deploying Joomla using Capistrano 2.0

That’s probably the major tagline of the whole Capistrano 2.0 saga. You can use it to deploy PHP, Django, or not doing any deployment at all. Let me demonstrate, this time using Joomla:

Capistrano adalah library/tool yang digunakan untuk meng-online-kan aplikasi Ruby on Rails, tapi bisa juga digunakan untuk aplikasi PHP, misalnya Joomla:

ceefour@ojalanow:~/project/layout_mania/trunk$ cap deploy
  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
  * executing "svn checkout -q --username ceefour --no-auth-cache -r11 http://tools.assembla.com/svn/layout_mania/trunk /home/rainbow/apps/layout_mania/releases/20070814160555 && (echo 11 > /home/rainbow/apps/layout_mania/releases/20070814160555/REVISION)"
    servers: ["rainbowpurple.com"]
    [rainbowpurple.com] executing command
    command finished
  * executing `deploy:finalize_update'
  * executing "chmod -R g+w /home/rainbow/apps/layout_mania/releases/20070814160555"
    servers: ["rainbowpurple.com"]
    [rainbowpurple.com] executing command
    command finished
    triggering after callbacks for `deploy:finalize_update'
  * executing `deploy:symlink_secret'
  * executing "ln -s /home/rainbow/apps/layout_mania/secret /home/rainbow/apps/layout_mania/releases/20070814160555/secret"
    servers: ["rainbowpurple.com"]
    [rainbowpurple.com] executing command
    command finished
  * executing `deploy:use_live_configuration'
  * executing "cp -f /home/rainbow/apps/layout_mania/releases/20070814160555/joomla/configuration.php.live /home/rainbow/apps/layout_mania/releases/20070814160555/joomla/configuration.php"
    servers: ["rainbowpurple.com"]
    [rainbowpurple.com] executing command
    command finished
  * executing `deploy:symlink_cache'
  * executing "rm -rf /home/rainbow/apps/layout_mania/releases/20070814160555/joomla/cache && ln -s /home/rainbow/apps/layout_mania/shared/cache /home/rainbow/apps/layout_mania/releases/20070814160555/joomla/cache"
    servers: ["rainbowpurple.com"]
    [rainbowpurple.com] executing command
    command finished
  * executing `deploy:symlink'
  * executing "rm -f /home/rainbow/apps/layout_mania/current && ln -s /home/rainbow/apps/layout_mania/releases/20070814160555 /home/rainbow/apps/layout_mania/current"
    servers: ["rainbowpurple.com"]
    [rainbowpurple.com] executing command
    command finished
 ** transaction: commit
  * executing `deploy:restart'

The result? layout-mania.humblia.com. Below is the source code of deploy/config.rb used to deploy this Joomla app.

Hasilnya? layout-mania.humblia.com. Di bawah ini adalah source code dari file konfigurasi Capistrano deploy/config.rb yang digunakan untuk aplikasi ini.

set :application, "layout_mania"
set :repository,  "http://tools.assembla.com/svn/layout_mania/trunk"

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
set :deploy_to, "/home/rainbow/apps/#{application}"
set :user, "rainbow"
set :scm_username, 'ceefour'
set :use_sudo, false
set :cache_path, "#{shared_path}/cache"
set :media_path, "#{shared_path}/media"

# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion

role :app, "rainbowpurple.com"
role :web, "rainbowpurple.com"
role :db,  "rainbowpurple.com", :primary => true

after 'deploy:finalize_update', 'deploy:symlink_secret'
after 'deploy:finalize_update', 'deploy:use_live_configuration'
after 'deploy:finalize_update', 'deploy:symlink_cache'

namespace :deploy do

  # Overwritten to provide flexibility for people who aren't using Rails.
  task :setup, :except => { :no_release => true } do
    dirs = [deploy_to, releases_path, shared_path, cache_path, media_path]
    dirs += %w(system).map { |d| File.join(shared_path, d) }
    run "umask 02 && mkdir -p #{dirs.join(' ')}"
  end

  # Also overwritten to remove Rails-specific code.
  task :finalize_update, :except => { :no_release => true } do
    run "chmod -R g+w #{release_path}" if fetch(:group_writable, true)
  end

  # Each of the following tasks are Rails specific. They're removed.
  task :migrate do
  end

  task :migrations do
  end

  task :cold do
  end

  task :start do
  end

  task :stop do
  end

  # Do nothing (To restart apache, run 'cap deploy:apache:restart')
  task :restart do
  end

  task :use_live_configuration, :roles => :app do
    run "cp -f #{release_path}/joomla/configuration.php.live #{release_path}/joomla/configuration.php"
  end

  task :symlink_cache, :roles => :app do
    run "rm -rf #{release_path}/joomla/cache && ln -s #{cache_path} #{release_path}/joomla/cache"
  end
  task :symlink_secret, :roles => :app do
    run "ln -s #{deploy_to}/secret #{release_path}/secret"
  end

end

namespace :db do

  desc "Overwrite the remote database with local database."
  task :push_force, :roles => :db do
    system "mysqldump --opt rainbow_layoutmania | bzip2 > /tmp/rainbow_layoutmania.sql.bz2"
    system "rsync -vPa /tmp/rainbow_layoutmania.sql.bz2 rainbowpurple.com:tmp/"
    run "bunzip2 -dc /home/rainbow/tmp/rainbow_layoutmania.sql.bz2 | mysql -u rainbow_layoutma -p`cat #{deploy_to}/secret/db_password` rainbow_layoutmania"
    run "rm -f /home/rainbow/tmp/rainbow_layoutmania.sql.bz2"
    system "rm -f /tmp/rainbow_layoutmania.sql.bz2"
  end

  desc "Optimize remote database."
  task icon surprised Deploying Joomla using Capistrano 2.0 ptimize, :roles => :db do
    run "mysqlcheck --analyze --repair --optimize --user=rainbow_layoutma --password=`cat #{deploy_to}/secret/db_password` rainbow_layoutmania"
  end

end

Interested? Unfortunately this isn’t a tutorial. Look more on the resources below:

Tertarik? Sayang sekali ini bukan tutorial, coba cari informasi lebih lanjut di:

Note: Sorry for dual-language posting, any better suggestion? icon wink Deploying Joomla using Capistrano 2.0

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

  • http://blog.neofreko.com toni

    Any chance it would be useful for the case: not having access to live server shell?

    Or should I have to hack it a bit to push the files via ftp after checking out, or exporting?

  • http://hendy.gauldong.net/ Hendy Irawan

    Toni:

    Its functionality will be severely handicapped, but I think it may still be useful.

    Capistrano without SSH is more like plain Rake, or Ant (Java), or the old trusty Make.

    You can think of it like the question “is bash useful without cp, ls, mv?” It probably is still useful but I’m not really sure if it’s necessary.

    I’d instead propose the question is it really necessary (or worth it) to host your site on a service that doesn’t provide an SSH shell? Since nowadays you can afford it at very minimum price, and when you know the advantages of having a shell access (even a limited one, where you cannot compile stuff your own) having the ability to simply manage stuff on a Linux shell and using i.e. rsync, scp, is truly wonderful)

  • http://hendy.gauldong.net/ Hendy Irawan

    see http://www.adaruby.com/rails-hosting/ for freely available options

    Additionally, you can join http://groups.google.com/group/rubyonrails-deployment?hl=en and ask if someone owning a hosting service would want to give you a free account. There are some.

  • Pingback: Geek Building The Bridge Part 2 » Blog Archive » PHP Capistrano-like Deployment Tool

  • http://www.dollen.com Rj Dollen

    Deep. Who would have thought a search for R.O.R. would bring up one of my pictures.

  • http://hendy.gauldong.net/ Hendy Irawan

    Thanks Rj… I have to confess :D

    I found it very hard to resist your beautiful work/photograph :-) So I didn’t resist :)

  • http://www.outsourcingi.com Outsourcing

    I was recently given a coupon to unlimited downloads of Joomla Templates &

    Ajax Producs for only $10. I was told that the coupon is valid until 10/12/07

    and the purchase is a membership good for a year. The coupon is “Unlimited”.

    To redeem go to http://www.joomlacmssolutions.com and register for membership. When

    you get to the shopping cart submit the coupon and pay only $10. Their

    templates are really good and they launch one new template a month.

  • http://www.iopensuite.com/ Joomla ecommerce

    Any runtime you want — you’re able to bundle any javascript or 3rd party libraries with your app at your discretion. In our Developer app you can choose between a number of popular JS frameworks pre-baked like jQuery, Mootools, YUI, etc. Flash, Silverlight, and pretty much any “native” browser widgets have all been demoed in Titanium apps, so there’s no reason you couldn’t write your Titanium App in Flex, for example :)

  • Info

    How can i user serial port connector ? Internet way One computer 2 Another computer via net FILE_CREATE ?

  • Pingback: php

  • Pingback: Salina