<?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>Sean&#039;s Blog &#187; passenger app root</title>
	<atom:link href="http://seanbehan.com/tag/passenger-app-root/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Install and Serve a Rails Application from PHP Subdirectory Using Apache, Phussion Passenger and Ruby Enterprise Edition</title>
		<link>http://seanbehan.com/ruby-on-rails/install-and-serve-a-rails-application-from-php-subdirectory-using-apache-phussion-passenger-and-ruby-enterprise-edition/</link>
		<comments>http://seanbehan.com/ruby-on-rails/install-and-serve-a-rails-application-from-php-subdirectory-using-apache-phussion-passenger-and-ruby-enterprise-edition/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 21:40:02 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[feedzirra]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[mod rails]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[passenger app root]]></category>
		<category><![CDATA[path prefix]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phussion]]></category>
		<category><![CDATA[ree]]></category>
		<category><![CDATA[relative url rails]]></category>
		<category><![CDATA[routing]]></category>
		<category><![CDATA[ruby enterprise edition]]></category>
		<category><![CDATA[subdirectory]]></category>
		<category><![CDATA[VirtualHost]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=795</guid>
		<description><![CDATA[Here is how to install a Rails application out of a subdirectory (rather than as a subdomain) with the Apache web server(Apache2). In this example I&#8217;m going to use my own blog which is a WordPress installation and serve a Rails application from the subdirectory &#8220;reader&#8221;. Note, I&#8217;m not going to keep my Rails application [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Finstall-and-serve-a-rails-application-from-php-subdirectory-using-apache-phussion-passenger-and-ruby-enterprise-edition%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Install and Serve a Rails Application from PHP Subdirectory Using Apache, Phussion Passenger and Ruby Enterprise Edition" data-url="http://seanbehan.com/ruby-on-rails/install-and-serve-a-rails-application-from-php-subdirectory-using-apache-phussion-passenger-and-ruby-enterprise-edition/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Here is how to install a Rails application out of a subdirectory (rather than as a subdomain) with the Apache web server(Apache2). In this example I&#8217;m going to use my own blog which is a WordPress installation and serve a Rails application from the subdirectory &#8220;reader&#8221;. Note, I&#8217;m not going to keep my Rails application in the document root of my WordPress Blog, which is a PHP application and therefore anyone could browse the ruby source code :(. I&#8217;ll keep it elsewhere on the filesystem and tell Apache about the location in the VirtualHost file.</p>
<p>You can visit the application by going to  <a href="http://seanbehan.com/reader">http://seanbehan.com/reader</a>. The application just parses a bunch of RSS feeds and displays them.<br />
It uses the Feedzirra library, which I&#8217;ve also written about <a href="http://seanbehan.com/ruby-on-rails/installing-feedzirra-rss-parser-on-ubuntu-8/">http://seanbehan.com/ruby-on-rails/installing-feedzirra-rss-parser-on-ubuntu-8/</a>.</p>
<p>I&#8217;m using Phussion Passenger and Ruby Enterprise Edition from the folks at <a href="http://www.modrails.com/">Mod Rails</a>. Installing both Phussion Passenger and Ruby Enterprise Edition is simple and a very well documented process. However, you&#8217;ll need to download and compile them from source. If you install Ruby Enterprise Edition (REE) it comes w/ Passenger so you won&#8217;t need to download it separately. I recommend going with REE. <a href="http://www.rubyenterpriseedition.com/download.html">http://www.rubyenterpriseedition.com/download.html</a></p>
<h3>Installing Ruby Enterprise Edition</h3>
<p>Here are the commands to download and install (change the X.X.X to the package you&#8217;ve actually downloaded).</p>
<pre class="wp-code-highlight prettyprint">
wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz
tar xzvf ruby-enterprise-X.X.X.tar.gz
./ruby-enterprise-X.X.X/installer
</pre>
<p>When you run the installer you&#8217;ll be prompted for an installation location. Just hit enter to install in the default location. Follow the instructions from there and remember to copy/paste any code that they give you.</p>
<p>Official Instructions on installation for Passenger on its own are available here <a href="http://www.modrails.com/install.html">http://www.modrails.com/install.html</a> I&#8217;ve written about setting up an entire box w/ Passenger here <a href="http://seanbehan.com/ruby-on-rails/new-ubuntu-slice-apache-mysql-php-ruby-on-rails-git-and/">http://seanbehan.com/ruby-on-rails/new-ubuntu-slice-apache-mysql-php-ruby-on-rails-git-and/</a> If you already have Passenger installed and want to use REE just download and install REE and it&#8217;ll recompile Passenger with REE support if you follow the instructions.</p>
<p>*** If you install REE you&#8217;ll need to either link or reinstall all your gems. I linked the REE gem with the one in /usr/bin so that I can run  gem install <gem name> and REE will be aware of it.</p>
<pre class="wp-code-highlight prettyprint">
ln -s /opt/ruby-enterprise-X.X.X/bin/gem /usr/bin/gem
</pre>
<h3>The VirtualHost</h3>
<p>If you have Passenger and REE successfully installed you&#8217;ll need to modify your VirtualHost file and add Rails application information to it.</p>
<pre class="wp-code-highlight prettyprint">
&amp;lt;VirtualHost *&amp;gt;
  # Normal virtual host info
  ServerName seanbehan.com
  ServerAlias *.seanbehan.com
  DocumentRoot /var/www/seanbehan.com/wordpress

  # Rails info goes here
  Alias /reader /var/www/seanbehan.com/reader/public
  &amp;lt;Location /reader&amp;gt;
    PassengerAppRoot /var/www/seanbehan.com/reader
    RailsEnv production
  &amp;lt;/Location&amp;gt;
&amp;lt;/VirtualHost&amp;gt;
</pre>
<p>The &#8220;Location&#8221; directive tells apache to forward requests starting with /reader to the directory<br />
/var/www/seanbehan.com/reader/public which is the location of our Rails app. However, we need to add the PassengerAppRoot assignment so that it knows where the actual application lives.</p>
<h3>Routing in Rails with Relative Path</h3>
<p>And finally, your Rails application will need to be aware of the relative url prefix assigned to each route. Normally, you could do this w/ the :path_prefix at the individual route level like so</p>
<pre class="wp-code-highlight prettyprint">
map.resources :feeds, :path_prefix =&gt; &quot;reader&quot;
</pre>
<p>This will work but you can add a line to your RAILS_ROOT/config/environments/production.rb file which will handle all your routes for you. This way you don&#8217;t need to setup a relative path on your development environment work.</p>
<pre class="wp-code-highlight prettyprint">
# in RAILS_ROOT/config/environments/production.rb
config.action_controller.relative_url_root = '/reader'
</pre>
<h3>Final Thoughts</h3>
<p>Remember Ruby Enterprise Edition is the new Ruby Interpreter that your Rails web applications are using. If you<br />
have any gem or rake issues make sure that you&#8217;re using the same interpreter that REE is using. Look in the location<br />
installation of REE &#8220;/opt/ruby-ent&#8230;&#8221; bin/gem or bin/rake and see if that helps. I just linked those to the standard /usr/bin/gem and /usr/bin/rake and everything worked fine.</p>
<p>Also I&#8217;ve read some people have trouble using the alias with passenger. This may be an older issue but works for me without a problem on Ubuntu (latest).</p>
<p>Here are some useful resources I found along the way&#8230;</p>
<p>http://robots.thoughtbot.com/post/159806388/phusion-passenger-with-a-prefix</p>
<p>http://www.modrails.com/documentation/Users%20guide.html#deploying_rails_to_sub_uri</p>
<p>http://www.modrails.com/documentation/Users%20guide.html#RailsBaseURI</p>
<p>http://stackoverflow.com/questions/848258/server-prefix-and-rails-routes</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/install-and-serve-a-rails-application-from-php-subdirectory-using-apache-phussion-passenger-and-ruby-enterprise-edition/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

