<?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; mongrel</title>
	<atom:link href="http://blog.bhushangahire.net/tag/mongrel/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>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>Deploying two rails application with Apache + mongrel on windows</title>
		<link>http://blog.bhushangahire.net/2008/01/28/deploying-two-rails-application-with-apache-mongrel-on-windows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=deploying-two-rails-application-with-apache-mongrel-on-windows</link>
		<comments>http://blog.bhushangahire.net/2008/01/28/deploying-two-rails-application-with-apache-mongrel-on-windows/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 12:20:56 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[mongrel]]></category>

		<guid isPermaLink="false">http://www.bhushangahire.net/?p=32</guid>
		<description><![CDATA[Install Ruby, Gems and then install Ruby on Rails: sudo gem install rails --include-dependencies Now download and install Apache 2.2 using, as the fastest way, the msi package. Now enable the needed modules (url rewriting, proxy, proxy_balancer e proxy_http) by editing the httpd.conf file (under c:Apache_Software_FoundationApache2.2conf, if you installed Apache in its standard path). You [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #000000;">Install Ruby, <a class="alinks_links" title="the Ruby standard for publishing and managing third party libraries" onclick="return alinks_click(this);" rel="external" href="http://rubyforge.org/projects/rubygems/">Gems</a> and then install Ruby on Rails:</span></p>
<p class="wp_syntax"><span style="color: #000000;"><br />
</span></p>
<p class="code"><span style="color: #000000;"><br />
</span></p>
<pre><span style="color: #000000;"><code>sudo gem install rails --include-dependencies</code></span></pre>
<p><span style="color: #000000;">Now download and install Apache 2.2 using, as the fastest way, <a href="http://apache.markoer.org/httpd/binaries/win32/apache_2.2.6-win32-x86-no_ssl.msi">the msi package</a>.</span></p>
<p><span style="color: #000000;">Now enable the needed modules (url rewriting, proxy, proxy_balancer e proxy_http) by editing the httpd.conf file (under c:Apache_Software_FoundationApache2.2conf, if you installed Apache in its standard path). You just need to uncomment the following lines (remove the #):</span></p>
<p class="wp_syntax"><span style="color: #000000;"><br />
</span></p>
<p class="code"><span style="color: #000000;"><br />
</span></p>
<p><span style="color: #000000;"><code>LoadModule rewrite_module modules/mod_rewrite.so<br />
LoadModule proxy_module modules/mod_proxy.so<br />
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so<br />
LoadModule proxy_http_module modules/mod_proxy_http.so</code></span></p>
<p><span style="color: #000000;">Install the mongrel and mongrel_service gems:</span></p>
<p class="wp_syntax"><span style="color: #000000;"><br />
</span></p>
<p class="code"><span style="color: #000000;"><br />
</span></p>
<pre><span style="color: #000000;">gem install mongrel (pick last version for win32)
gem install mongrel_service (pick last version for win32)</span></pre>
<p><span style="color: #000000;">Now we will create a mongrel cluster of 2 windows services responding at http://127.0.0.1 on ports 3010, 3011 serving a rail application at the path c:wwwrormyapp  that will be started from the windows system user. The two windows services will be respectively named mongrel_myapp1 and mongrel_myapp2. Open the command prompt and type:</span></p>
<p class="wp_syntax"><span style="color: #000000;"><br />
</span></p>
<p class="code"><span style="color: #000000;"><br />
</span></p>
<pre style="margin: 0pt; overflow: visible; clear: none; float: none; width: auto;"><span style="color: #000000;">mongrel_rails service::install -N mongrel_myapp1 -p 3010 -e production -c c:wwwrormyapp
mongrel_rails service::install -N mongrel_myapp2 -p 3011 -e production -c c:wwwrormyapp</span></pre>
<p style="color: #ffffff"><span style="color: #000000;">Now open the windows services tool, make the 2 new services have an automatic startup type (so they will still be started when you reboot).<br />
Test if your application is now running at the two ports: </span></p>
<p class="wp_syntax"><span style="color: #000000;"><br />
</span></p>
<p class="code"><span style="color: #000000;"><br />
</span></p>
<pre><span style="color: #000000;">http://localhost:3010

http://localhost:3011</span></pre>
<p><span style="color: #000000;">If everything is working fine, you are ready to place Apache in front of these 2 mongrel services, to manage the load balancing of you application.</span></p>
<p><span style="color: #000000;">The best way to configure Apache is to create a Virtual Host for your ROR application. First edit your httpd.conf file, and uncomment the following line:</span></p>
<p class="wp_syntax"><span style="color: #000000;"><br />
</span></p>
<p class="code"><span style="color: #000000;"><br />
</span></p>
<pre style="margin: 0pt; overflow: visible; clear: none; float: none; width: auto;"><span style="color: #000000;"># Virtual hosts

Include conf/extra/httpd-vhosts.conf</span></pre>
<p><span style="color: #000000;">Now edit the httpd-vhosts.conf file, like this (keep the slashes in the *nix fashion!):</span></p>
<p class="wp_syntax"><span style="color: #000000;"><br />
</span></p>
<p class="code"><span style="color: #000000;"><br />
</span></p>
<pre class="xml"><span style="color: #000000;">NameVirtualHost *:80

#Proxy balancer section (create one for each ruby app cluster)
<span style="font-weight: bold;">&lt;Proxy</span> balancer://myapp_cluster<span style="font-weight: bold;">&gt;</span>
  BalancerMember http://myapp:3010
  BalancerMember http://myapp:3011
<span style="font-weight: bold;">&lt;/Proxy<span style="font-weight: bold;">&gt;</span></span>

#Virtual host section (create one for each ruby app you need to publish)

<span style="font-weight: bold;">&lt;VirtualHost</span> *:80<span style="font-weight: bold;">&gt;</span>
  ServerName myapp
  DocumentRoot c:/www/ror/myapp/public/

  <span style="font-weight: bold;">&lt;Directory</span> c:/www/ror/myapp/public/ <span style="font-weight: bold;">&gt;</span>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
  <span style="font-weight: bold;">&lt;/Directory<span style="font-weight: bold;">&gt;</span></span>

  #log files
  ErrorLog /var/log/apache2/myapp_error.log
  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn
  CustomLog /var/log/apache2/myapp_access.log combined

  #Rewrite stuff
   RewriteEngine On

  # Check for maintenance file and redirect all requests
  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /system/maintenance.html [L]

  # Rewrite index to check for static
  RewriteRule ^/$ /index.html [QSA]

  # Rewrite to check for Rails cached page
  RewriteRule ^([^.]+)$ $1.html [QSA]

  # Redirect all non-static requests to cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://myapp_cluster%{REQUEST_URI} [P,QSA,L]

<span style="font-weight: bold;">&lt;/VirtualHost<span style="font-weight: bold;">&gt;</span></span></span></pre>
<p><span style="color: #000000;">Add your app as a host in hosts.file (in the c:WINNTsystem32driversetc folder):</span></p>
<p class="wp_syntax"><span style="color: #000000;"><br />
</span></p>
<p class="code"><span style="color: #000000;"><br />
</span></p>
<pre class="text"><span style="color: #000000;">127.0.0.1 localhost
127.0.0.1 myapp</span></pre>
<p><span style="color: #000000;">Restart now Apache from the Windows services panel, and if everything is fine you should have your app served by Apache at the following url:</span></p>
<p><span style="color: #000000;">http://myapp</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2008/01/28/deploying-two-rails-application-with-apache-mongrel-on-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

