Setting up Capistrano with LxAdmin and Lighttpd

Article Details
Article ID: 11
Created On: 30 May 2008 01:28 PM

Answer The following is a simple example of using Capistrano with RailsPlayground using the svn repository on

--We assume that the SVN repository is created using the svn control panel on
-- Also make sure you have setup your rails application in LxAdmin as described here.
-- On Windows you will need SVN installed.
-- You can download it at: for your OS.

1. First you will need to create the initial directory structure in your SVN repository. This can be done using svn from your local machine:

svn mkdir
svn mkdir
svn mkdir

2. Import a Rails application from your local application into the repository.

svn import local_application_path

3. Install capistrano on your local machine

gem install capistrano
capify /full/path/to/railsapp

- This will create a deploy.rb in the /config directory of your local rails application. - The contents of the file should look like this. The application variable should be the same name you gave the application in LxAdmin.

set :user, 'root'
set :scm_username, "svnusername"
set :scm_password, "svnpassword"
set :server, 'ipofyourvps'
set :domain_name, ''
set :application, 'application'
set :repository, "{application}/trunk"
role :web, server
role :app, server
role :db,  server, :primary => true
set :use_sudo, false

set :deploy_to, "/home/admin/ror/#{domain_name}/#{application}-cap"

task :restart_web_server, :roles => :app do
    run "killall -9 dispatch.fcgi"
  rescue Exception => error
    puts "No dispatchers were running so there was nothing to kill"
  run "/etc/init.d/lighttpd restart /dev/null 2>&1 "

task :after_update_code, :roles => [:web, :db, :app] do
  run "chmod 755 #{release_path}/public/dispatch.fcgi"
  run "chown admin:admin #{release_path} -R"
  run "chown admin:admin #{deploy_to}/shared -R"
  run "rm -rf /home/admin/ror/#{domain_name}/#{application}"
  run "ln -s #{release_path} /home/admin/ror/#{domain_name}/#{application}"
  run "(echo '0a'; echo \"ENV['RAILS_ENV'] ||= 'production'\"; echo '.'; echo 'wq') | ed -s #{release_path}/config/environment.rb"

after "deploy:start", :restart_web_server
after "deploy:restart", :restart_web_server

4. Run the following command locally to setup capistrano on the railsplayground server.

cap deploy:setup

5. Now you can deploy your app by using the following command

cap deploy

*Common Problems* - Only in the case of Fastcgi. Make sure your dispatch.cgi/dispatch.fcgi file has the correct shebang line. It should look like this:


- Before deploying please make sure to edit database.yml to point to the correct database.

Feel free to contact us at if you come across any issues with the same.