<?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>pastbedti.me &#187; passenger</title>
	<atom:link href="http://www.pastbedti.me/tag/passenger/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pastbedti.me</link>
	<description>About ruby, rails, postgresql and stuff....</description>
	<lastBuildDate>Fri, 02 Apr 2010 20:12:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Deploying a Sinatra app with Apache and Phusion Passenger a.k.a. mod_rack</title>
		<link>http://www.pastbedti.me/2009/11/deploying-a-sinatra-app-with-apache-and-phusion-passenger-a-k-a-mod_rack/</link>
		<comments>http://www.pastbedti.me/2009/11/deploying-a-sinatra-app-with-apache-and-phusion-passenger-a-k-a-mod_rack/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 22:01:30 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[webroot]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=610</guid>
		<description><![CDATA[My Sinatra + Apache + Passenger setup did not just run  
Deploying a simple Sinatra rack application under Apache and Phusion Passenger turned out not work out of the box for me. 
I already had a virtual host so I decided to deploy with passengers sub URI (sub URI documentation).
To make this work you&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<h3>My Sinatra + Apache + Passenger setup did not just run <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </h3>
<p>Deploying a simple Sinatra rack application under Apache and Phusion Passenger turned out not work out of the box for me. </p>
<p>I already had a virtual host so I decided to deploy with passengers sub URI (<a href="http://www.modrails.com/documentation/Users%20guide.html#deploying_rack_to_sub_uri" target="_blank">sub URI documentation</a>).</p>
<p>To make this work you&#8217;ll need Apache installed with Phusion Passenger setup (<a href="http://www.modrails.com/install.html" target="_blank">Passenger installation</a>)</p>
<p>
<h3>This is what I started with</h3>
<p>This is my folders for the already existing website.</p>
<p>[cc lang="bash"]<br />
# Existing homedir<br />
/home/my_web/<br />
# Current webroot<br />
/home/my_web/htdocs<br />
[/cc]</p>
<p>
<h3>Creating folders and files for Sinatra</h3>
<p>The first thing you want to do is to create folders and files for Sinatra.</p>
<p>[cc lang=bash]<br />
mkdir /home/my_web/sinatra<br />
[/cc]</p>
<p>[cc lang=bash]<br />
cd /home/my_web/sinatra<br />
mkdir tmp<br />
mkdir logs<br />
mkdir public<br />
touch app.rb<br />
touch config.ru<br />
[/cc]</p>
<p>
<h3>Create symlink</h3>
<p>Create a symbolic link from our current webroot to the new Sinatra app so that apache/passenger can find it.</p>
<p>[cc lang="bash"]<br />
ln -s /home/my_web/sinatra/public /home/my_web/htdocs/app<br />
[/cc]</p>
<p>
<h3>Creating the application</h3>
<p>We also need a Sinatra application for this to work so lets fill those files.</p>
<p>
<h4>File: config.ru</h4>
<p>[cc lang="ruby"]<br />
require &#8216;app&#8217;</p>
<p>set :environment, ENV['RACK_ENV'].to_sym<br />
set :app_file,     &#8216;app.rb&#8217;<br />
disable :run</p>
<p>log = File.new(&#8220;logs/sinatra.log&#8221;, &#8220;a&#8221;)<br />
STDOUT.reopen(log)<br />
STDERR.reopen(log)</p>
<p>run Sinatra::Application<br />
[/cc]</p>
<p>
<h4>File: app.rb</h4>
<p>[cc lang="ruby"]<br />
require &#8216;rubygems&#8217;<br />
require &#8217;sinatra&#8217;</p>
<p>before do<br />
  # Strip the last / from the path<br />
  request.env['PATH_INFO'].gsub!(/\/$/, &#8221;)<br />
end</p>
<p>get &#8221; do<br />
   &#8220;Hello world&#8221;<br />
end<br />
[/cc]</p>
<p>
<h3>Apache configuration</h3>
<p>Now we need to setup apache so that it can find our Sinatra app and load it.</p>
<p>The only thing you need to do is add the following line to your existing VirtualHost block:<br />
[cc lang="apache"]<br />
RackBaseURI /app<br />
[/cc]<br />
This line will tell passenger to look into our existing webroot for a symlink thats named app and which points to our rack app.  (<a href="http://www.modrails.com/documentation/Users%20guide.html#RackBaseURI" target="_blank">RackBaseURI  documentation</a>)</p>
<p>
<h3>Virtual host entry</h3>
<p>[cc lang="apache"]<br />
<VirtualHost *:80><br />
  ServerName www.example.com<br />
  ServerAlias example.com<br />
  DocumentRoot /home/my_web/htdocs/<br />
  RackBaseURI /app</p>
<p>  <Directory "/home/my_web/htdocs/"><br />
    Order allow,deny<br />
    Allow from all<br />
    AllowOverride All<br />
  </Directory><br />
</VirtualHost><br />
[/cc]</p>
<p>The best part is that you are allowed to specify this option multiple times. So you can easily setup multiple apps under the same virtual host.</p>
<p>Cheers! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/11/deploying-a-sinatra-app-with-apache-and-phusion-passenger-a-k-a-mod_rack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
