21 Jan 2017 
Support Center » Knowledgebase » Setting up Capistrano with LxAdmin and Lighttpd
 Setting up Capistrano with LxAdmin and Lighttpd
Solution The following is a simple example of using Capistrano with RailsPlayground using the svn repository on yourdomain.svnrepository.com.

--We assume that the SVN repository is created using the svn control panel on domain.svnrepository.com.
-- 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: http://subversion.apache.org/packages.html 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 http://domainname.svnrepository.com/svn/application/trunk
svn mkdir http://domainname.svnrepository.com/svn/application/branches
svn mkdir http://domainname.svnrepository.com/svn/application/tags

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

svn import local_application_path http://domainname.svnrepository.com/svn/applicationname/trunk

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, 'domainname.com'
set :application, 'application'
set :repository, "http://yourdomain.svnrepository.com/svn/#{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 support@railsplayground.com if you come across any issues with the same.

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

 Login [Lost Password] 
Remember Me:
 Article Options
Home | Register | Submit a Ticket | Knowledgebase | News | Downloads

Help Desk Software By Kayako eSupport v3.30.02