<?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>apocryph.org &#187; passenger</title>
	<atom:link href="http://apocryph.org/tag/passenger/feed/" rel="self" type="application/rss+xml" />
	<link>http://apocryph.org</link>
	<description>Notes to my future self</description>
	<lastBuildDate>Mon, 09 Aug 2010 16:59:34 +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>Moving to Future Hosting, Part III</title>
		<link>http://apocryph.org/2008/09/29/moving_future_hosting_part_iii/</link>
		<comments>http://apocryph.org/2008/09/29/moving_future_hosting_part_iii/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 23:06:58 +0000</pubDate>
		<dc:creator>anelson</dc:creator>
				<category><![CDATA[Migrated from Drupal]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[futurehosting]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[tech diary]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://apocryph.org/?p=580</guid>
		<description><![CDATA[In this episode of Moving to FutureHosting, I&#8217;ll be installing and configuring Apache2, the mpm-worker multiprocessing module, passenger (aka mod_rails), Ruby, Ruby on Rails, and all associated cruft. I&#8217;ve done this before on Ubuntu using aptitude, but since FutureHosting runs CentOS, which uses the yum package manager, this will be a new experience for me. [...]]]></description>
			<content:encoded><![CDATA[<p>In this episode of <em>Moving to FutureHosting</em>, I&#8217;ll be installing and configuring Apache2, the <code>mpm-worker</code> multiprocessing module, passenger (aka <code>mod_rails</code>), Ruby, Ruby on Rails, and all associated cruft.  I&#8217;ve done this before on Ubuntu using <code>aptitude</code>, but since FutureHosting runs CentOS, which uses the <code>yum</code> package manager, this will be a new experience for me.</p>
<h2>Apache2</h2>
<p>My FutureHosting box came with Apache2.  <code>/usr/sbin/httpd -v</code> reports <code>Server version: Apache/2.2.9 (Unix)</code>, which seems fine.</p>
<h2>Which MPM?</h2>
<p>Apache2 supports multiple concurrency models for handling more than one connection at once.  Each model is implemented in a Multi-Processing Model (MPM).  <code>prefork-mpm</code> causes Apache to fork off a number of processes on startup, each of which will process some requests.  <code>worker-mpm</code> creates multiple worker threads within a process to handle requests.  I&#8217;ve read that the latest versions of Passenger work well with <code>worker-mpm</code>, which has the added advantage of being less memory-hungry than a bunch of forked processes.</p>
<p>I don&#8217;t know how to tell what MPM the existing install is using.  I <code>grep</code>&#8216;d all the <code>LoadModule</code> directives in the HTTP configuration files in <code>/etc/httpd/conf/</code> but I don&#8217;t see anything pertaining to an mpm.  <code>/usr/sbin/httpd -l</code> lists <code>prefork.c</code> but no <code>worker.c</code>.  This tells me the version of Apache that comes with CentOS 5 is built without support for worker-mpm.  Ubuntu has handy aptitude packages for both MPMs, so you install the one you want and it configures Apache accordingly.  CentOS seems to be missing that.  I&#8217;ll go with <code>prefork</code> for now until I can figure out how to change it.</p>
<h2>Ruby</h2>
<p>The latest version of Ruby available as a yum package is 1.8.5-5.  Um, no.  That&#8217;s ancient.  That means I have to build from source.  Out-<em>fucking</em>-standing.  Why does anyone run CentOS anyway?</p>
<p>No matter, the forum thread <a href="http://www.centos.org/modules/newbb/viewtopic.php?topic_id=11821">here</a> pointed me to a custom repository some guy is running, with the latest Ruby 1.8.6 bits.  Pathetic that it came to that.  I installed <code>ruby</code>, <code>ruby-devel</code>, <code>ruby-irb</code>, <code>ruby-mysql</code>, and <code>ruby-rdoc</code>.</p>
<h2>Ruby Gems</h2>
<p>I installed Ruby Gems from the same source as above, which then pulled in a dizzying dependency chain of additional packages, nearly 60 (!!) in all.  The installation seemed to work, though, so I can&#8217;t complain.</p>
<h2>Ruby on Rails</h2>
<p>Rails is easy.  <code>sudo gem install rails</code>.  QED.</p>
<h2>Passenger</h2>
<p>Phusion Passenger runs Rails apps in Apache fast and reliably.  What more is there to say?</p>
<p>It&#8217;s distributed as a Ruby gem, so</p>
<p><code>sudo gem install passenger</code></p>
<p>And Passenger is installed.  But it needs to be configured as a module in Apache2.  For that there&#8217;s</p>
<p><code>sudo passenger-install-apache2-module</code></p>
<p>Which builds the Apache module from source, and spits out the appropriate verbiage for httpd.conf.  The httpd configuration stuff is in <code>/etc/httpd/conf</code>, which includes files in <code>/etc/httpd/conf/extras</code>.  In keeping with this idiom, I created a new file, <code>/etc/httpd/conf/httpd-passenger.conf</code>, to contain the Passenger-related configuration:</p>
<pre><code>LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3
PassengerRuby /usr/bin/ruby
</code></pre>
<p>which I include in <code>/etc/httpd/conf/httpd.conf</code> using an <code>Include</code> directive.</p>
<p>After that, <code>sudo apachectl restart</code> and the module was loaded.</p>
<h2>Ruby Enterprise Edition</h2>
<p>Phusion (makers of Passenger) offer an &#8216;enterprise&#8217; edition of the Ruby interpreter that works with Passenger to reduce memory load and increase performance.  I&#8217;ve never used it before, but I&#8217;d like to give it a try.</p>
<p>After downloading and extracting the source tarball, there&#8217;s no familiar <code>configure</code>/<code>make</code>/<code>make install</code> cycle.  Instead there&#8217;s an <code>installer</code> script that takes you through the installation.</p>
<p>I accepted the default install directory (<code>/opt/ruby-enterprise-1.8.6-20080810</code>), and off it went building from source.  I don&#8217;t have any Postgres components installed, so it choked trying to install Postgres support, which I don&#8217;t give a shit about.  I can always install it later with <code>/opt/ruby-enterprise-1.8.6-20080810/bin/ruby /opt/ruby-enterprise-1.8.6-20080810/bin/gem install postgres</code>.</p>
<p>And that was it.  To cause Passenger to use Ruby EE, I changed the <code>PassengerRuby</code> line in the <code>httpd-passenger.conf</code> file to:</p>
<pre><code>PassengerRuby /opt/ruby-enterprise-1.8.6-20080810/bin/ruby
</code></pre>
<p>Too easy!</p>
<h2>Testing</h2>
<p>To verify Passenger and Ruby EE are working, I need a Rails app to serve.  I&#8217;ll create one in my home directory and make Apache use that as the root for the default <code>VirtualHost</code>:</p>
<pre><code>rails passtest
</code></pre>
<p>to create the project.</p>
<pre><code>script/generate controller itworked
</code></pre>
<p>failed with:</p>
<pre><code>Rails requires RubyGems &gt;= 1.1.1 (you have 0.9.4). Please `gem update --system` and try again.
</code></pre>
<p>Yikes!  I had no idea I was running ancient gems.  <code>sudo gem update --system</code> made quick work of that problem.</p>
<p>Now, as I was saying,</p>
<pre><code>script/generate controller itworked
</code></pre>
<p>It spit out an annoying error:</p>
<pre><code>/usr/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/rails_generator/lookup.rb:211:in 'each' is outdated
</code></pre>
<p>but otherwise seemed to work.</p>
<p>Now <code>~anelson/passtest/public</code> is the public root for my rails app, which I need to point Passenger to.</p>
<p>For now I&#8217;ll just use one of the <code>VirtualHost</code> entries in <code>/etc/httpd/conf/extras/httpd-vhost.conf</code>, since I&#8217;m just testing.</p>
<p>And&#8230;it worked!  I pointed <code>DocumentRoot</code> to the <code>public</code> folder in my Rails project, and got the default Rails screen.  It seems to be working.  Yay.</p>
]]></content:encoded>
			<wfw:commentRss>http://apocryph.org/2008/09/29/moving_future_hosting_part_iii/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
