<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>eXpand yOur cReativity &#187; capistrano</title>
	<atom:link href="http://blog.bhushangahire.net/tag/capistrano/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bhushangahire.net</link>
	<description></description>
	<lastBuildDate>Thu, 05 Jan 2012 07:17:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Setup Capistrano to deploy Rails application on Amazon EC2 with Git</title>
		<link>http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git</link>
		<comments>http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 06:22:49 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[capistrano]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=155</guid>
		<description><![CDATA[1: Create a new Rails app &#8211; we&#8217;ll call is &#8216;deploytest&#8217; $ rails deploytest $ cd deploytest 2: Create a local Git repository for it $ git init $ git add * $ git commit -a -m 'initial commit' $ git status 3: Create a couple of Capistrano files $ capify . 4: Edit config/deploy.rb [...]]]></description>
			<content:encoded><![CDATA[<div class="post-body entry-content">1: Create a new Rails app &#8211; we&#8217;ll call is &#8216;deploytest&#8217;</p>
<pre class="prettyprint"><span class="pln">$ rails deploytest
$ cd deploytest</span></pre>
<p>2: Create a local Git repository for it</p>
<pre class="prettyprint"><span class="pln">$ git init
$ git add </span><span class="pun">*</span><span class="pln">
$ git commit </span><span class="pun">-</span><span class="pln">a </span><span class="pun">-</span><span class="pln">m </span><span class="str">'initial commit'</span><span class="pln">
$ git status</span></pre>
<p>3: Create a couple of Capistrano files</p>
<pre class="prettyprint"><span class="pln">$ capify </span><span class="pun">.</span></pre>
<p>4: Edit config/deploy.rb</p>
<pre class="prettyprint"><span class="com"># The name of your app</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">application</span><span class="pun">,</span><span class="pln"> </span><span class="str">"deploytest"</span><span class="pln">
</span><span class="com"># The directory on the EC2 node that will be deployed to</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">deploy_to</span><span class="pun">,</span><span class="pln"> </span><span class="str">"/var/www/apps/#{application}"</span><span class="pln">
</span><span class="com"># The type of Source Code Management system you are using</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">scm</span><span class="pun">,</span><span class="pln"> </span><span class="pun">:</span><span class="pln">git
</span><span class="com"># The location of the LOCAL repository relative to the current app</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">repository</span><span class="pun">,</span><span class="pln">  </span><span class="str">"."</span><span class="pln">
</span><span class="com"># The way in which files will be transferred from repository to remote host</span><span class="pln">
</span><span class="com"># If you were using a hosted github repository this would be slightly different</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">deploy_via</span><span class="pun">,</span><span class="pln"> </span><span class="pun">:</span><span class="pln">copy

</span><span class="com"># The address of the remote host on EC2 (the Public DNS address)</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">location</span><span class="pun">,</span><span class="pln"> </span><span class="str">"ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com"</span><span class="pln">
</span><span class="com"># setup some Capistrano roles</span><span class="pln">
role </span><span class="pun">:</span><span class="pln">app</span><span class="pun">,</span><span class="pln"> location
role </span><span class="pun">:</span><span class="pln">web</span><span class="pun">,</span><span class="pln"> location
role </span><span class="pun">:</span><span class="pln">db</span><span class="pun">,</span><span class="pln">  location</span><span class="pun">,</span><span class="pln"> </span><span class="pun">:</span><span class="pln">primary </span><span class="pun">=&gt;</span><span class="pln"> </span><span class="kwd">true</span><span class="pln">

</span><span class="com"># Set up SSH so it can connect to the EC2 node - assumes your SSH key is in ~/.ssh/id_rsa</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">user</span><span class="pun">,</span><span class="pln"> </span><span class="str">"root"</span><span class="pln">
ssh_options</span><span class="pun">[:</span><span class="pln">keys</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[</span><span class="typ">File</span><span class="pun">.</span><span class="pln">join</span><span class="pun">(</span><span class="pln">ENV</span><span class="pun">[</span><span class="str">"HOME"</span><span class="pun">],</span><span class="pln"> </span><span class="str">".ssh"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"id_rsa"</span><span class="pun">)]</span><span class="pln">
</span></pre>
<p>The only account on a default EC2 instance is root. You probably want to create a second user that is responsible for your application.</p>
<p>5: Copy your SSH public key to your EC2 node</p>
<pre class="prettyprint"><span class="pln">$ scp </span><span class="pun">-</span><span class="pln">i </span><span class="pun">~</span><span class="str">/my-ec2-keypair ~/</span><span class="pun">.</span><span class="pln">ssh</span><span class="pun">/</span><span class="pln">id_rsa</span><span class="pun">.</span><span class="pln">pub root@ec2</span><span class="pun">-</span><span class="lit">xxx</span><span class="pun">-</span><span class="lit">xxx</span><span class="pun">-</span><span class="lit">xxx</span><span class="pun">-xxx</span><span class="lit">.compute</span><span class="pun">-</span><span class="lit">1.amazonaws</span><span class="pun">.</span><span class="pln">com</span><span class="pun">:</span><span class="str">/root/</span><span class="pun">.</span><span class="pln">ssh</span><span class="pun">/</span><span class="pln">authorized_keys2</span></pre>
<p>NOTE the filename authorized_keys2 &#8211; not authorized_keys!!</p>
<p>6: Setup the EC2 node for Capistrano deployment.<br />
From your LOCAL machine, not the EC2 node:</p>
<pre class="prettyprint"><span class="pln">$ cap deploy</span><span class="pun">:</span><span class="pln">setup</span></pre>
<p>7: Finally, deploy your application</p>
<pre class="prettyprint"><span class="pln">$ cap deploy</span></pre>
<p>You will see lots of output and with this dummy application some of those will report errors/warnings. Don&#8217;t worry about that for now.</p>
<p>8: Check that the Deployment was successful<br />
Connect to the EC2 node with SSH the regular way, cd to the app directory and check that everything is there. If that is all working then you are ready to deploy a real application and add custom tasks for managing the database, restarting the server etc.</p>
<p>Bear in mind that Capistrano add new &#8216;releases&#8217; of your software in separate directories and symlinks the &#8216;current&#8217; directory to the latest. So the root of your deployed application is the &#8216;current&#8217; subdirectory.</p>
<p>Hope this will help you setting up your ec2 instance with capistrano.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Step-By-Step setup slicehost server (fedora) for rails application.</title>
		<link>http://blog.bhushangahire.net/2009/07/22/step-by-step-setup-slicehost-server-fedora-for-rails-application/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=step-by-step-setup-slicehost-server-fedora-for-rails-application</link>
		<comments>http://blog.bhushangahire.net/2009/07/22/step-by-step-setup-slicehost-server-fedora-for-rails-application/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 10:11:00 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[capistrano]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[setup]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=136</guid>
		<description><![CDATA[Hi all as I worked on setting up 4 to 5 servers, I thought its better to document the stuff so that I/developers can refer it, So I am documenting the step-by-step process for setting up the slicehost server for rails application work with nginx as a web server and mongrel as a rails application [...]]]></description>
			<content:encoded><![CDATA[<div id="content"><!--single.php--></p>
<p><!--loop--></p>
<p><!--post title--></p>
<div class="post-meta-top">
<div class="clearboth"></div>
<p><!--content with more link--></p>
<div>Hi all as I worked on setting up 4 to 5 servers, I thought its better to document the stuff so that I/developers can refer it, So I am documenting the step-by-step process for setting up the slicehost server for rails application work with <strong>nginx</strong> as a web server and <strong>mongrel</strong> as a rails application server.</div>
<div>
<h2>Update</h2>
<div class="level2">
<p>To update your system:</p>
<blockquote><p>yum update</p></blockquote>
</div>
<h2>MySQL</h2>
<div class="level2">
<p>to install mysql client and server apps</p>
<blockquote><p>yum install mysql-server</p></blockquote>
<p>The client package “mysql” will automatically be installed as a dependency.</p></div>
<h2>Apache</h2>
<div class="level2">
<blockquote><p>yum install httpd</p></blockquote>
</div>
<h2>PHP5</h2>
<div class="level2">
<p>To install php with soap, xml and mysql plugins:</p>
<blockquote><p>yum install php php-soap php-xml php-mysql</p></blockquote>
<p>some other php plugin utilities that are common:</p>
<blockquote><p>yum install php-mbstring php-gd</p></blockquote>
</div>
<h2>Ruby</h2>
<div class="level2">
<blockquote><p>yum install ruby</p></blockquote>
</div>
<h2>Utilities</h2>
<div class="level2">
<p>other useful utilities:</p>
<blockquote><p>yum install nano wget elinks subversion vi</p></blockquote>
</div>
</div>
<div>
<h2>Nginx</h2>
<div class="level2">
<p>install nginx web server:</p>
<blockquote><p>yum install nginx</p></blockquote>
</div>
<h2>Mongrel Cluster</h2>
<div class="level2">
<p>install mongrel_cluster:</p>
<blockquote><p>gem install mongrel_cluster –include-dependencies</p></blockquote>
</div>
<p>Setup your nginx configuration for your rails application and mongrel_cluster (proxy).</p>
<p>Below you found sample config file for nginx.conf (normally located in “/etc/nginx/conf/nginx.conf”)</p>
<blockquote>
<pre>user  deploy;
worker_processes  1;
error_log   logs/error.log debug;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
  include        conf/mime.types;
  default_type   application/octet-stream;
  sendfile        on;
  #tcp_nopush     on;
  keepalive_timeout  65;
  tcp_nodelay        on;
  gzip  on;
  gzip_min_length  1100;
  gzip_buffers     4 8k;
  gzip_types       text/plain;
  upstream mongrel {
    server 127.0.0.1:8000;
    server 127.0.0.1:8001;
  }
  server {
    listen       80;
    server_name  example.com;
    root /var/www/apps/example/current/public;
    index  index.html index.htm;
    location / {
      proxy_set_header  X-Real-IP  $remote_addr;
      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect false;
      if (-f $request_filename/index.html) {
        rewrite (.*) $1/index.html break;
      }
      if (-f $request_filename.html) {
        rewrite (.*) $1.html break;
      }
      if (!-f $request_filename) {
        proxy_pass http://mongrel;
        break;
      }
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
  }
}</pre>
</blockquote>
</div>
<p>Restart the nginx server:</p>
<blockquote><p>/etc/init.d/nginx restart</p></blockquote>
<div>
<h2>Mongrel Configuration:</h2>
<p>Now Go to the application directory and create a configuration for Mongrel:</p>
<blockquote><p>mongrel_rails cluster::configure -e production -p 8000 -a 127.0.0.1 -N 2 -c /home/APP/production/APP/current</p></blockquote>
<p>it will create the config/mongrel_cluster.yml file; basically you do not need to edit it.</p>
<p>You can test cluster with</p>
<p>To Start:</p>
<blockquote><p>mongrel_rails cluster::start</p></blockquote>
<p>To Stop:</p>
<blockquote><p>mongrel_rails cluster::stop</p></blockquote>
<p>To Restart:</p>
<blockquote><p>mongrel_rails cluster::restart</p></blockquote>
</div>
<div>
<h2>Capistrano Configuration:</h2>
<p>Then create a configuration for Capistrano:</p>
<blockquote><p>cap –apply-to .</p></blockquote>
<p>we need to modify the generated file config/deploy.rb:</p>
<blockquote>
<pre>require 'mongrel_cluster/recipes'

#you set the APP name with the cap command
set :application, "APP"
#a path to your repository
set :repository, "svn+ssh://USERNAME@SVN_SERVER/projects/#{application}/trunk"

role :web, "SERVER"
role :app, "SERVER"
role :db, "SERVER", :primary =&gt; true

#where to deploy (copy the files) on the server; I created a special user APP for the</pre>
<pre>application (if you do not like it, replace the /home/#{application} part with your path
set :deploy_to, "/home/#{application}/production/#{application}"
set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml"
#if the server login name is different to the development computer login name; in my case</pre>
<pre>the user name is the APP nameset :user, "APP"</pre>
</blockquote>
<p>Make necessary changes to the config/database.yml file.</p></div>
<div>
<h2>Capistrano Deployment:</h2>
<p>Create the basic structure on the server:</p>
<blockquote><p>cap deploy:setup</p></blockquote>
<p>For the first deployment you can use cold deploy:</p>
<blockquote><p>cap cold_deploy</p></blockquote>
<p>After that for next deployments you have to use:</p>
<blockquote><p>cap deploy</p></blockquote>
<p>You can also run migration from capistrano with:</p>
<blockquote><p>cap deploy:migrate<sup>*</sup></p></blockquote>
<p><sup>*</sup> Note: It wont work for me, it migrating to the previous release available in the releses folder, So I suggest you manually run migration on server.</div>
<div>
<p>That’s it, your server is ready to run.</p>
<p>Hope this documentation will be helpful to you, Enjoy <img src='http://blog.bhushangahire.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</div>
<p><!--for paginate posts--></p>
<p><!--Post Meta--></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2009/07/22/step-by-step-setup-slicehost-server-fedora-for-rails-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Send mail after capistrano deployment</title>
		<link>http://blog.bhushangahire.net/2008/05/07/send-mail-after-capistrano-deployment/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=send-mail-after-capistrano-deployment</link>
		<comments>http://blog.bhushangahire.net/2008/05/07/send-mail-after-capistrano-deployment/#comments</comments>
		<pubDate>Wed, 07 May 2008 12:53:26 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[capistrano]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[mail]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=40</guid>
		<description><![CDATA[I got a very good plugin at http://code.google.com/p/capistrano-mailer/. Just copied the details below to have use in future. It is a Capistrano Plugin AND a Rails Plugin Ever wanted to be emailed whenever someone on the team does a cap deploy of trunk or some tag to some server. Wouldn&#8217;t it be nice to know [...]]]></description>
			<content:encoded><![CDATA[<p>I got a very good plugin at <a href="http://code.google.com/p/capistrano-mailer/">http://code.google.com/p/capistrano-mailer/</a>.<br />
Just copied the details below to have use in future.</p>
<h2><strong>It is a Capistrano Plugin AND a Rails Plugin</strong></h2>
<p>Ever wanted to be emailed whenever someone on the team does a cap deploy of trunk or some tag to some server.   Wouldn&#8217;t it be nice to know about it every time a release was deployed?  For large rails projects this type of coordination is essential,  and this plugin makes sure everyone on the need to know list is notified when something new is deployed.</p>
<p>This plugin is an extension to Capistrano.</p>
<p>That means it registers itself with Capistrano as a plugin and is therefore available to call in your recipes.</p>
<p>If you are looking to roll your own email integration into capistrano then try this pastie: <a rel="nofollow" href="http://pastie.org/146264">http://pastie.org/146264</a> (thanks to  	 	 Mislav Marohni?). But if you want to take the easy road to riches then keep reading <img src='http://blog.bhushangahire.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<blockquote><p>&#8211; figurative &#8220;riches&#8221; of course, I promise nothing in return for your using this plugin</p></blockquote>
<h2>Requirements</h2>
<ul>
<li>Rails 2.0.2 </li>
<li>Capistrano 2.1.0 &#8211; 2.2.0 </li>
</ul>
<h2>Installation</h2>
<pre class="prettyprint">./script/plugin install http://capistrano-mailer.googlecode.com/svn/trunk/capistrano_mailer</pre>
<h2><a id="Usage">Usage</a></h2>
<h4>1. Install the plugin.</h4>
<h4>2. Add this line to the top of your deploy.rb:</h4>
<pre class="prettyprint">
<blockquote>require 'vendor/plugins/capistrano_mailer/lib/capistrano_mailer'</blockquote>
</pre>
<h4>3. Add a cap_mailer_settings.rb file to your config/ directory:</h4>
<pre class="prettyprint">require 'vendor/plugins/capistrano_mailer/lib/cap_mailer'

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address        =&gt; "mail.default.com",
:port           =&gt; 25,
:domain         =&gt; 'default.com',
:perform_deliveries =&gt; true,
:user_name      =&gt; "releases@default.com",
:password       =&gt; "mypassword",
:authentication =&gt; :login }
ActionMailer::Base.default_charset = "latin1"

CapMailer.template_root = "vendor/plugins/capistrano_mailer/views/"
CapMailer.recipient_addresses = ["dev1@default.com"]
CapMailer.sender_address = %("Capistrano Deployment" &lt;releases@default.com&gt;)
CapMailer.email_prefix = "[MYSITE-CAP-DEPLOY]"
CapMailer.site_name = "MySite.com"
CapMailer.email_content_type = "text/html"</pre>
<h4>4. Add these two tasks to your deploy.rb:</h4>
<pre class="prettyprint">namespace :show do
desc "Show some internal Cap-Fu: What's mah NAYM?!?"
task :me do
set :command, task_call_frames.first.task.fully_qualified_name
puts "Running #{command} task"
end
end

namespace :deploy do
...

desc "Send email notification of deployment"
task :notify, :roles =&gt; :app do
show.me
mailer.send(rails_env, repository, command, deploy_to, host)
end

...
end</pre>
<p>Make <em>sure</em> you&#8217;ve defined <tt>rails_env</tt>, <tt>repository</tt>, <tt>deploy_to</tt> and <tt>host</tt>.  <tt>command</tt> is defined by the <tt>show:me</tt> task above.</p>
<p>The only <strong>required</strong> parameters to <tt>mailer.send</tt> are <tt>rails_env</tt>, <tt>repository</tt>, <tt>command</tt> and <tt>deploy_to</tt>. The <strong>complete</strong> set of possible parameters is:</p>
<pre class="prettyprint">mailer.send(rails_env, repository, command, deploy_to, host = nil, ip_address = nil, output = nil)</pre>
<p>If anyone has a cool way of <em>recording the <strong>output</strong> into a capistrano accessible variable</em>,  so that it can be shoved into the release email that would be an excellent contribution!</p>
<h4>5. Then add the hook somewhere in your deploy.rb:</h4>
<pre class="prettyprint">after "deploy", "deploy:notify"</pre>
<h4>6. Enjoy and Happy Capping!</h4>
]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2008/05/07/send-mail-after-capistrano-deployment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

