<?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>Jetpack Flight Log &#187; ruby</title>
	<atom:link href="http://jetpackweb.com/blog/tags/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://jetpackweb.com/blog</link>
	<description>Rock{et}ing the interweb</description>
	<lastBuildDate>Sun, 12 Jun 2011 17:51:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Install Phusion Passenger (a.k.a. mod_rails) on cPanel Server</title>
		<link>http://jetpackweb.com/blog/2009/07/21/install-phusion-passenger-a-k-a-mod_rails-on-cpanel-server/</link>
		<comments>http://jetpackweb.com/blog/2009/07/21/install-phusion-passenger-a-k-a-mod_rails-on-cpanel-server/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 18:06:56 +0000</pubDate>
		<dc:creator>Brian Racer</dc:creator>
				<category><![CDATA[cpanel]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[passenger]]></category>

		<guid isPermaLink="false">http://jetpackweb.com/blog/?p=129</guid>
		<description><![CDATA[Although cPanel has built in support for running Ruby or Rails apps, it uses Mongrel as the server and doesn&#8217;t allow more than one instance per user. That makes it pretty useless for any application that gets even a moderate amount of traffic. Instead we can install]]></description>
			<content:encoded><![CDATA[<p>Although cPanel has built in support for running Ruby or Rails apps, it uses <a href="http://mongrel.rubyforge.org/" target="_blank">Mongrel</a> as the server and doesn&#8217;t allow more than one instance per user. That makes it pretty useless for any application that gets even a moderate amount of traffic. Instead we can install <a href="http://www.modrails.com/" target=_blank" />Phusion Passenger</a> (a.k.a mod_rails), which in my opinion is a much nicer solution anyway.</p>
<p>First we need to make sure Ruby is installed via a cpanel script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">sudo</span> <span class="sy0">/</span>script<span class="sy0">/</span>installruby</pre></div></div>

<p>Now we can install the passenger gem:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">sudo</span> gem <span class="kw2">install</span> passenger</pre></div></div>

<p>Next, compile the apache2 module</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">sudo</span> passenger-install-apache2-module</pre></div></div>

<p>The installer may tell you that the the Apache development headers are needed and will suggest &#8216;yum install httpd-devel&#8217;. Since cPanel compiles it&#8217;s own version of apache, yum is configured to ignore that package. That is OK, because the program we need is already installed, we just have to tell Passenger where to find it.</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="re2">APXS2</span>=<span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>apache<span class="sy0">/</span>bin<span class="sy0">/</span>apxs <span class="re2">PATH</span>=<span class="re1">$PATH</span>:<span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>apache<span class="sy0">/</span>bin passenger-install-apache2-module</pre></div></div>

<p>Everything should go OK this time, and the installer will give you a few lines to add to your apache config file. It&#8217;s best practice with cPanel not to put these in your main httpd.conf, but rather the pre_main_global.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">vi</span> <span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>apache<span class="sy0">/</span>conf<span class="sy0">/</span>includes<span class="sy0">/</span>pre_main_global.conf
&nbsp;
LoadModule passenger_module <span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>ruby<span class="sy0">/</span>gems<span class="sy0">/</span><span class="nu0">1.8</span><span class="sy0">/</span>gems<span class="sy0">/</span>passenger-X.X.X<span class="sy0">/</span>ext<span class="sy0">/</span>apache2<span class="sy0">/</span>mod_passenger.so
PassengerRoot <span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>ruby<span class="sy0">/</span>gems<span class="sy0">/</span><span class="nu0">1.8</span><span class="sy0">/</span>gems<span class="sy0">/</span>passenger-X.X.X
PassengerRuby <span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span>ruby</pre></div></div>

<p>Now we need to setup passenger to run on a per virtual host basis. Open up the httpd.conf file and find the virtual host you want to run a Rails app and add this line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">Include <span class="st0">&quot;/usr/local/apache/conf/userdata/std/2/username/domain_name/*.conf&quot;</span></pre></div></div>

<p>Replace <i>username</i> with the username of the account.</p>
<p>Now we need to create the directory we just specified, and also create a configuration file letting passenger know it should load for this host:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">mkdir</span> <span class="re5">-p</span> <span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>apache<span class="sy0">/</span>conf<span class="sy0">/</span>userdata<span class="sy0">/</span>std<span class="sy0">/</span><span class="nu0">2</span><span class="sy0">/</span>username<span class="sy0">/</span>domain_name<span class="sy0">/</span>
<span class="kw2">vi</span> <span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>apache<span class="sy0">/</span>conf<span class="sy0">/</span>userdata<span class="sy0">/</span>std<span class="sy0">/</span><span class="nu0">2</span><span class="sy0">/</span>username<span class="sy0">/</span>domain_name<span class="sy0">/</span>rails.conf
&nbsp;
RailsBaseURI <span class="sy0">/</span></pre></div></div>

<p>To make sure those files load, run this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="sy0">/</span>scripts<span class="sy0">/</span>ensure_vhost_includes <span class="re5">--user</span>=username</pre></div></div>

<p>We need to make sure cPanel records the changes we have for when it rebuilds those files, so run the following two commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>cpanel<span class="sy0">/</span>bin<span class="sy0">/</span>apache_conf_distiller <span class="re5">--update</span>
<span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>cpanel<span class="sy0">/</span>bin<span class="sy0">/</span>build_apache_conf</pre></div></div>

<p>We can now restart apache:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="sy0">/</span>etc<span class="sy0">/</span>init.d<span class="sy0">/</span>httpd restart</pre></div></div>

<p>Since by default the Apache Document Root for each host is /home/username/public_html, you will probably need to symlink that to your applications public directory:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">ln</span> <span class="re5">-s</span> <span class="sy0">/</span>home<span class="sy0">/</span>username<span class="sy0">/</span>railsapp<span class="sy0">/</span>public <span class="sy0">/</span>home<span class="sy0">/</span>username<span class="sy0">/</span>public_html</pre></div></div>

<p>To restart that application, you just need to touch the restart.txt file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">touch</span> <span class="sy0">/</span>home<span class="sy0">/</span>username<span class="sy0">/</span>railsapp<span class="sy0">/</span>tmp<span class="sy0">/</span>restart.txt</pre></div></div>

<p>And there you have it, a working high performance rail application server on cPanel! For more information on tuning the Passenger configuration, read the <a href="http://www.modrails.com/documentation/Users%20guide%20Apache.html" target="_blank">complete docs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jetpackweb.com/blog/2009/07/21/install-phusion-passenger-a-k-a-mod_rails-on-cpanel-server/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

