Just one damn thing after another

yatender.com


Deploying php projects with capistrano

written by yatender
at 6:03 pm
on July 14, 2010
in Life
no comments

Using Ruby conventions have gotten quite popular to many web developmet environment across many languages . Sun have created a whole language to imitate the programming practices that were being in use for many years in Ruby On Rails they have called it groovy on grails.

One of the unique practices in Ruby on rails is the cool migration scripts and another is the use of capistrano for automated deployment.

Capistrano is though build for the deployment of Ruby on Rails application but it can be used to almost any other web development language and framework.

I have created such a deployment script to automate deployment for a Ecommerce site built in magento.The number of servers currently are two, one is the staging server and another is production.

so begin with install capistrano like this

sudo gem install capistrano

create a small rails application using

rails myapp

cd to get in this directory and now type.

capify

For the new version of capistrano you can define the number of server environment by using line like this in the deploy.rb

require ‘capistrano/ext/multistage’

for this you will need capistrano multistage gem. so install it like this

sudo gem install capistrano-ext

the staging and production server scripts can be defined like this

set :stages, %w(staging production)
set :default_stage, “staging”

create a folder named deploy in config directory.

Now define your staging and production setting by creating files like this

staging.rb and production.rb

The staging.rb from inside will look like this

set :repository, “svn or git repository url”
set :deploy_to, “folder name where to put deployed releases”
role :web, ‘ip name of the server’
role :app, ‘ip name of the server’

now define the task in deploy.rb for before and after deployment and things you want to do at the time of deployment.

I have defined the command to clear the var folders like cache and session, after the main deployment process is finished.Also i kept the var and media folder in a static location and created symlinks just after deployment to point to these folders.

Now in command line go to myapp

cd myapp

cap staging deploy

the deployment will try to do the default tasks for Ruby on Rails application , but it will not anyway impact the php application that you deployed.


 
 

about this

fineprint
yatender.com uses Wordpress.