<?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>John Yerhot - Weblog &#187; Deploy</title>
	<atom:link href="http://www.johnyerhot.com/tag/deploy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johnyerhot.com</link>
	<description>moof</description>
	<lastBuildDate>Mon, 16 Aug 2010 22:11:50 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mongrel + Nginx: Deploying to a subdirectory</title>
		<link>http://www.johnyerhot.com/2008/05/27/mongrel-nginx-deploying-to-a-subdirectory/</link>
		<comments>http://www.johnyerhot.com/2008/05/27/mongrel-nginx-deploying-to-a-subdirectory/#comments</comments>
		<pubDate>Wed, 28 May 2008 01:45:51 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Geeky]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[Deploy]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Subdirectory]]></category>
		<category><![CDATA[Virtual Hosts]]></category>

		<guid isPermaLink="false">http://www.johnyerhot.com/?p=64</guid>
		<description><![CDATA[Though using subdomains is all the rage right now, there are certianly instances where you may want to deploy your rails application to a subdirectory such as:
http://www.johnyerhot.com/myrailsapp
Of course Nginx makes it super easy to do so.  If you need to get your webserver ready with Nginx, PHP running as a FCGI instance, and Rails [...]]]></description>
			<content:encoded><![CDATA[<p>Though using subdomains is all the rage right now, there are certianly instances where you may want to deploy your rails application to a subdirectory such as:</p>
<p><code>http://www.johnyerhot.com/myrailsapp</code></p>
<p>Of course Nginx makes it super easy to do so.  If you need to get your webserver ready with Nginx, PHP running as a FCGI instance, and Rails check out my <a href="http://www.johnyerhot.com/2008/02/12/how-to-nginx-fcgi-php-mysql-ruby-on-rails-rewrite-vhosts/">other how to</a>.  </p>
<p>Now, onward!</p>
<p>First create a new virtual host.  In my case, for <code>yerhot.org</code> it would look like this:<br />
<code>server {<br />
listen   80;<br />
server_name yerhot.org;<br />
access_log /var/www/yerhot.org/logs/access.log;<br />
error_log /var/www/yerhot.org/logs/error.log;<br />
location / {<br />
root   /var/www/yerhot.org/;<br />
index  index.html;<br />
}<br />
}</code><br />
Pretty simple setup, telling Nginx to listen on port 80 for requests for yerhot.org, where to store logs, and finally setting up the site root at /var/www/yerhot.org.</p>
<p>All we would have to do to have Nginx redirect to our Rails app when looking for yerhot.org/myrailsapp is make <strong>another</strong> location block (in other words, place this right before the last curly brace).</p>
<p><code> location /myrailsapp {<br />
proxy_pass        http://localhost:8000;<br />
}</code><br />
Now, all requests for /myrailsapp will get proxied to port 8000.  Now fire up your Rails app on port 8000.<br />
<code>mongrel_rails start -e production -p 8000 -d</code><br />
Restart Nginx:<br />
<code>/etc/init.d/nginx stop<br />
/etc/init.d/nginx start</code><br />
And&#8230;.<br />
<a href="http://www.johnyerhot.com/wp-content/uploads/2008/05/error.png"><img class="alignnone size-medium wp-image-65" title="error" src="http://www.johnyerhot.com/wp-content/uploads/2008/05/error.png" alt="" width="300" height="78" /></a><br />
Crap. Rails is looking for a &#8216;myrailsapp&#8217; route, which there is none.  No, no, don&#8217;t create one &#8211; we&#8217;ll need to use a little known feature of Mongrel to fix the problem.. the prefix.<br />
Stop Mongrel&#8230;<br />
<code>mongrel_rails stop</code><br />
And try this:<br />
<code>mongrel_rails start -e production -p 8000 -d --prefix=/myrailsapp</code></p>
<p>And&#8230; your app should fire right up.  Pretty neat, if you wanted to you could use it forward to a Mongrel Cluster, a FCGI instance of PHP (from my other post), or lots of stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.johnyerhot.com/2008/05/27/mongrel-nginx-deploying-to-a-subdirectory/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
