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 /home/rainbow/apps/layout_mania/releases/20070814160555 && (echo 11 > /home/rainbow/apps/layout_mania/releases/20070814160555/REVISION)"
    servers: [""]
    [] executing command
    command finished
  * executing `deploy:finalize_update'
  * executing "chmod -R g+w /home/rainbow/apps/layout_mania/releases/20070814160555"
    servers: [""]
    [] 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: [""]
    [] executing command
    command finished
  * executing `deploy:use_live_configuration'
  * executing "cp -f /home/rainbow/apps/layout_mania/releases/20070814160555/joomla/ /home/rainbow/apps/layout_mania/releases/20070814160555/joomla/configuration.php"
    servers: [""]
    [] 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: [""]
    [] 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: [""]
    [] executing command
    command finished
 ** transaction: commit
  * executing `deploy:restart'

The result? Below is the source code of deploy/config.rb used to deploy this Joomla app.

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

set :application, "layout_mania"
set :repository,  ""

# 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, ""
role :web, ""
role :db,  "", :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(' ')}"

  # 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)

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

  task :migrations do

  task :cold do

  task :start do

  task :stop do

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

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

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


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"
    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"

  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"


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.

  • 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?

  • Hendy Irawan


    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)

  • Hendy Irawan

    see for freely available options

    Additionally, you can join 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

  • Rj Dollen

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

  • 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 :)

  • 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 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.

  • 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