<?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>Common Media, Inc. &#187; Phusion Passenger</title>
	<atom:link href="http://www.commonmediainc.com/category/ruby-on-rails/phusion-passenger-ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.commonmediainc.com</link>
	<description>Online Communities and Web Development</description>
	<lastBuildDate>Fri, 06 May 2011 15:10:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Nginx configuration tweaks for client-side speed optimization</title>
		<link>http://www.commonmediainc.com/2010/05/06/nginx-configuration-tweaks-for-client-side-speed-optimization/</link>
		<comments>http://www.commonmediainc.com/2010/05/06/nginx-configuration-tweaks-for-client-side-speed-optimization/#comments</comments>
		<pubDate>Fri, 07 May 2010 00:02:39 +0000</pubDate>
		<dc:creator>pjmorse</dc:creator>
				<category><![CDATA[Phusion Passenger]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[browser performance]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[page speed]]></category>
		<category><![CDATA[YSlow]]></category>

		<guid isPermaLink="false">http://www.commonmediainc.com/?p=167</guid>
		<description><![CDATA[As we move more sites to an Nginx/Passenger server stack, we need to translate the server-side optimizations we use for browser-side performance from Apache configuration to Nginx. Here&#8217;s how that comes over: Gzip compression In Nginx, this is an optional module which should be built in to the software at compile time. If it&#8217;s present, [...]]]></description>
			<content:encoded><![CDATA[<p>As we move more sites to an Nginx/Passenger server stack, we need to translate <a href="http://www.commonmediainc.com/2008/03/27/y-be-slow/">the server-side optimizations we use for browser-side performance</a> from Apache configuration to Nginx. Here&#8217;s how that comes over:</p>
<h5>Gzip compression</h5>
<p>In Nginx, this is an optional module which should be built in to the software at compile time. If it&#8217;s present, you can activate it in site configuration with a block like this:</p>
<pre> gzip on;
 gzip_min_length  1100;
 gzip_buffers     4       8k;
 gzip_proxied     any;
 gzip_types       text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;</pre>
<p>Note that Nginx considers <code>text/xml</code> and <code>text/html</code> to be redundant MIME types.</p>
<h5>Long expiration dates</h5>
<p>We want to have our assets cached in the user&#8217;s browser cache as long as possible, with a few exceptions (e.g. advertising assets.) To that end, we set expiration headers:</p>
<pre>       location ~* \.(js|css|jpg|jpeg|gif|png)$ {
                if (-f $request_filename) {
                   expires                        max;
                   break;
                }
       }</pre>
<p>This uses the filename extension to determine which files get &#8220;far future&#8221; expiration dates. If you&#8217;re used to naming files without extensions, this might not work so well for you.</p>
<p>By default, Nginx doesn&#8217;t use Etags, so we can stop worrying about that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.commonmediainc.com/2010/05/06/nginx-configuration-tweaks-for-client-side-speed-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passenger, Paperclip, and Permissions (another route)</title>
		<link>http://www.commonmediainc.com/2009/06/09/passenger-paperclip-and-permissions-another-route/</link>
		<comments>http://www.commonmediainc.com/2009/06/09/passenger-paperclip-and-permissions-another-route/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 15:41:28 +0000</pubDate>
		<dc:creator>pjmorse</dc:creator>
				<category><![CDATA[Phusion Passenger]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[amazon s3]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[paperclip]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://www.commonmediainc.com/?p=112</guid>
		<description><![CDATA[We had issues with file uploads recently on a site using Paperclip to handle uploads and served with Passenger. The site worked fine in development, but in production the uploads would fail. Checking the production log showed that Paperclip was producing the following error: [paperclip] An error was received while processing: #&#60;Paperclip::NotIdentifiedByImageMagickError: /tmp/passenger.1358/var/stream.25635.1 is not [...]]]></description>
			<content:encoded><![CDATA[<p>We had issues with file uploads recently on a site using <a href="http://www.thoughtbot.com/projects/paperclip">Paperclip</a> to handle uploads and served with <a href="http://www.modrails.com">Passenger</a>. The site worked fine in development, but in production the uploads would fail. Checking the production log showed that Paperclip was producing the following error:</p>
<pre>[paperclip] An error was received while processing: #&lt;Paperclip::NotIdentifiedByImageMagickError: /tmp/passenger.1358/var/stream.25635.1 is not recognized by the 'identify' command.&gt;</pre>
<p>A web search produced <a href="http://railsforum.com/viewtopic.php?id=18627">this railsforum thread</a> with some helpful advice, specifically to set</p>
<pre>Paperclip.options[:command_path] = "/usr/local/bin"</pre>
<p>in an initializer for Paperclip. Our problem was environment-specific, though, so we put it in the <code>config/environment/production.rb</code> file instead. No luck.</p>
<p>So I checked the Apache logs to see what error Passenger was producing. It wasn&#8217;t throwing an error of its own; instead we were seeing a lot of</p>
<pre>[DEPRECATION] S3 support through RightAWS is deprecated. S3 support will be changed to AWS::S3 in a future version.</pre>
<p>&#8230;in the Apache error log. It turned out that our development boxes were all using <a href="http://amazon.rubyforge.org/">the <code>aws-s3</code> gem</a>, and the production box was still on <a href="http://rightaws.rubyforge.org/"><code>RightAWS</code></a>. When we installed <code>aws-s3</code> on the server, the problem was solved.</p>
<p>So if you&#8217;re having Passenger and Paperclip problems, make sure you&#8217;re using the right interface with s3 as part of your troubleshooting process.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.commonmediainc.com/2009/06/09/passenger-paperclip-and-permissions-another-route/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving a Rails/Mongrel site to Phusion Passenger on Ubuntu</title>
		<link>http://www.commonmediainc.com/2009/03/15/moving-a-railsmongrel-site-to-phusion-passenger-on-ubuntu/</link>
		<comments>http://www.commonmediainc.com/2009/03/15/moving-a-railsmongrel-site-to-phusion-passenger-on-ubuntu/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 18:58:30 +0000</pubDate>
		<dc:creator>pjmorse</dc:creator>
				<category><![CDATA[Phusion Passenger]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[phusion passenger]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.commonmediainc.com/?p=91</guid>
		<description><![CDATA[As I&#8217;ve noted before, several of our Rails projects are hosted using Phusion Passenger. We&#8217;ve been helping HitFix explore this option in recent weeks because it solves several minor deployment and restart frustrations they&#8217;ve been grappling with, and in the process I wrote up this walk-through for the installation. This process is actually really easy [...]]]></description>
			<content:encoded><![CDATA[<p>As <a title="Phusion Passenger, Permissions, and Rails' Session Store" href="http://www.commonmediainc.com/2008/11/25/phusion-passenger-permissions-and-rails-session-store/">I&#8217;ve noted before,</a> several of our Rails projects are hosted using <a href="http://www.modrails.com/">Phusion Passenger</a>. We&#8217;ve been <a title="Our previous post about HitFix" href="http://www.commonmediainc.com/2008/12/31/hitfix-is-in-beta/">helping</a> <a title="HitFix" href="http://www.hitfix.com">HitFix</a> explore this option in recent weeks because it solves several minor deployment and restart frustrations they&#8217;ve been grappling with, and in the process I wrote up this walk-through for the installation.</p>
<p>This process is actually really easy and the <a href="http://www.modrails.com/install.html">instructions on the Passenger site</a> and those provided during the installation process are excellent. The glitch we ran in to is that recent versions of Ubuntu and/or Apache 2.2.x use a slightly different method of loading modules and module configuration. (I haven&#8217;t run in to this method often enough to have learned whether it&#8217;s new in Apache or in Ubuntu.)</p>
<p>Instead of using one monolithic configuration file, sometimes offloading host configuration to included files, these Apaches instead globally include all modules found in the <code>mods_enabled</code> subdirectory of the Apache directory. Each module has two files, a <code>.load</code> file and a <code>.conf</code> file. The <code>.load</code> file contains only the LoadModule configuration directive; the <code>.conf</code> file contains any configuration directives.</p>
<p>Now, the actual files live in the <code>mods_available</code> subdirectory of Apache, and activating a module just means adding a symlink to the relevant files in <code>mods_enabled</code>, then restarting Apache. Deactivating it just means removing the symlink and restarting again.</p>
<p>With that in mind, here&#8217;s the Passenger process:</p>
<ul>
<li>Install Passenger on the server. This <em>should</em> be as simple as:</li>
</ul>
<p><code>sudo gem install passenger</code><br />
<code>sudo passenger-install-apache2-module</code></p>
<ul>
<li>On one system, this second command actually told me that the Apache 2 Development Headers were missing. (Passenger needs these to compile the Apache module.) I needed to run <code>sudo apt-get install apache2-prefork-dev</code> to get these headers. This didn&#8217;t work on the first attempt, but running <code>sudo apt-get update</code> once or twice finally got me a successful install of that package. Running the <code>passenger-install-apache2-module</code> script then worked successfully. Note that you will need a compiler on the system in order to generate the Apache module. You would think you could take this for granted, but apparently not.</li>
</ul>
<p>At this point, the module is built. This is where we have to adapt Phusion&#8217;s original installation instructions. Essentially, the next step is to make sure the module is loaded by Apache. Here&#8217;s how I did this:</p>
<ul>
<li>Create a file at <code>/etc/apache2/mods-available/passenger.load</code> with the following content:</li>
</ul>
<blockquote><p><code>LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so</code></p></blockquote>
<ul>
<li>Create a file at <code>/etc/apache2/mods-available/passenger.conf</code> with the following content (I think the IfModule container may be optional, but I played safe):</li>
</ul>
<blockquote><p><code>&lt;IfModule passenger_module&gt;<br />
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6<br />
PassengerRuby /usr/bin/ruby1.8<br />
&lt;/IfModule&gt;</code></p></blockquote>
<ul>
<li>Create symbolic links to both those files from <code>/etc/apache2/mods-enabled/</code>, i.e.</li>
</ul>
<p><code>sudo ln -s /etc/apache2/mods-available/passenger.load /etc/apache2/mods-enabled/</code><br />
<code>sudo ln -s /etc/apache2/mods-available/passenger.conf /etc/apache2/mods-enabled/</code></p>
<p>We can restart Apache at this point without disturbing the existing site. Note that we can change which ruby is used (e.g. for <a title="Ruby Enterprise Edition" href="http://www.rubyenterpriseedition.com/">Ruby Enterprise Edition</a>) by altering the path at the <code>PassengerRuby</code> directive and restarting Apache.</p>
<p>To move a site to Passenger, you want to back up the file found at <code>/etc/apache2/sites-available/yoursite</code>, then edit it to make these changes:</p>
<ul>
<li>Change the <code>DocumentRoot</code> to the <code>public</code> directory of the app, e.g. <code>DocumentRoot /u/apps/yoursite/current/public</code></li>
<li>Comment out (with a <code>#</code>) all the lines related to the proxy, starting with the <code>Proxy balancer</code> definition and extending through all the <code>ProxyPass</code>, <code>ProxyPassReverse</code> and <code>ProxyPreserveHost</code> directives.</li>
<li>Restart Apache (<code>/etc/init.d/apache2 restart</code>). If something goes wrong, restore the backup you made of the configuration file and restart Apache again to restore the previous configuration.</li>
</ul>
<p>The final trick is to update the restart task in Capistrano to handle restarting Passenger and not Mongrel. This is actually pretty easy, particularly if you&#8217;ve already overloaded the restart task in your <code>config/deploy.rb</code> file. Just replace the line reading <code>run "mongrel_rails cluster::restart -C #{mongrel_config}"</code> with one reading <code>run "touch #{current_path}/tmp/restart.txt"</code> and we&#8217;re good to go. The start and stop tasks probably also needs tweaking to remove the mongrel commands–probably pasting the same command in for &#8220;start&#8221; will do the trick unless we feel like putting Apache commands in.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.commonmediainc.com/2009/03/15/moving-a-railsmongrel-site-to-phusion-passenger-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

