<?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>Technology Bits and Bytes &#187; Bhushan Ahire</title>
	<atom:link href="http://blogs.circlesource.com/author/bhushangahire/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.circlesource.com</link>
	<description>CircleSource Technical Talent ShowCase</description>
	<lastBuildDate>Thu, 10 Dec 2009 20:01:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Step-By-Step setup slicehost server (fedora) for rails application.</title>
		<link>http://blogs.circlesource.com/2008/07/29/step-by-step-setup-slicehost-server-fedora-for-rails-application/</link>
		<comments>http://blogs.circlesource.com/2008/07/29/step-by-step-setup-slicehost-server-fedora-for-rails-application/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 04:08:11 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[server setup]]></category>
		<category><![CDATA[slicehost]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=14</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>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 &#8211;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 &#8220;/etc/nginx/conf/nginx.conf&#8221;)</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&#8217;s it, your server is ready to run.<br />
Hope this documentation will be helpful to you, Enjoy <img src='http://blogs.circlesource.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2008/07/29/step-by-step-setup-slicehost-server-fedora-for-rails-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use Google Apps mail configuration with rails application.</title>
		<link>http://blogs.circlesource.com/2008/07/28/how-to-use-google-apps-mail-configuration-with-rails-application/</link>
		<comments>http://blogs.circlesource.com/2008/07/28/how-to-use-google-apps-mail-configuration-with-rails-application/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 04:06:52 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[google apps]]></category>
		<category><![CDATA[mail conf]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=13</guid>
		<description><![CDATA[I am using google apps for my domain www.bhushangahire.com
For one of my rails application I am using this domain mail account setup for sending mails.
But I am not able to send the mail with the default smtp setings we use for sending mail.
So I search on net and I found the Goggle Apps consider its [...]]]></description>
			<content:encoded><![CDATA[<p>I am using google apps for my domain <strong>www.bhushangahire.com</strong></p>
<p>For one of my rails application I am using this domain mail account setup for sending mails.<br />
But I am not able to send the mail with the default smtp setings we use for sending mail.</p>
<p>So I search on net and I found the Goggle Apps consider its in different way. Which is TLS ans SSH service, which is not by default comes with the Action mailler.</p>
<p class="vspace"><span class="wikiword">ActionMailer</span> can&#8217;t send emails using <span class="wikiword">GMail</span> out of the box. To add this functionality do the following configuration in your rails application:</p>
<ol>
<li>Create the file <strong><code>lib/smtp_tls.rb</code></strong>
<div class="code">
<pre>require "openssl"
require "net/smtp"

Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret

sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
@socket = Net::InternetMessageIO.new(sock)
@socket.read_timeout = 60 #@read_timeout

check_response(critical { recv_response() })
do_helo(helodomain)

raise 'openssl library not installed' unless defined?(OpenSSL)
starttls
ssl = OpenSSL::SSL::SSLSocket.new(sock)
ssl.sync_close = true
ssl.connect
@socket = Net::InternetMessageIO.new(ssl)
@socket.read_timeout = 60 #@read_timeout
do_helo(helodomain)

authenticate user, secret, authtype if user
@started = true
ensure
unless @started
# authentication failed, cancel connection.
@socket.close if not @started and @socket and not @socket.closed?
@socket = nil
end
end

def do_helo(helodomain)
begin
if @esmtp
ehlo helodomain
else
helo helodomain
end
rescue Net::ProtocolError
if @esmtp
@esmtp = false
@error_occured = false
retry
end
raise
end
end

def starttls
getok('STARTTLS')
end

def quit
begin
getok('QUIT')
rescue EOFError
rescue OpenSSL::SSL::SSLError
end
end
end</pre>
</div>
</li>
<li>Add the following lines to <strong><code>config/environment.rb</code></strong> and replace the values with the appropriate username and password:
<div class="code">
<pre>require 'smtp_tls'
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.server_settings = {
:address =&gt; "smtp.gmail.com",
:port =&gt; 587,
:domain =&gt; "mydomain.com",
:authentication =&gt; :plain,
:user_name =&gt; "username@mydomain.com",
:password =&gt; "password"
}</pre>
</div>
<p><strong><sup>*</sup>Note:</strong>To work your domain with <strong>&#8220;mydomain.com&#8221;</strong> you have to configure your <strong>MX records</strong> to work Gmail mail sending functionality out of box.</p>
<p>Else you can use a temporary address <strong>@mydomain.com.test-google-a.com</strong>, I have not tested with this as I have already configure my <strong>MX records</strong>.</p>
<p>You can get more information on changing <strong><a href="http://www.google.com/support/a/bin/answer.py?answer=33352">http://www.google.com/support/a/bin/answer.py?answer=33352</a></strong>.</p>
<p>Hope this information is useful to you. <img src='http://blogs.circlesource.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2008/07/28/how-to-use-google-apps-mail-configuration-with-rails-application/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
