<?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>Dimitri.eu &#187; mod_rails</title>
	<atom:link href="http://www.dimitri.eu/tag/mod_rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dimitri.eu</link>
	<description>About personal and IT-related occupations</description>
	<lastBuildDate>Fri, 30 Jul 2010 18:20:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Configure Ruby on Rails with Phusion Passenger (mod_rails)</title>
		<link>http://www.dimitri.eu/configure-ruby-on-rails-with-phusion-passenger-mod_rails/</link>
		<comments>http://www.dimitri.eu/configure-ruby-on-rails-with-phusion-passenger-mod_rails/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 18:20:49 +0000</pubDate>
		<dc:creator>Dimi</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[mod_rails]]></category>
		<category><![CDATA[Phusion Passenger]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.dimitri.eu/?p=169</guid>
		<description><![CDATA[The configuration of a new Ruby on Rails (RoR) environment has always been a bit of a struggle thanks to mongrel, mod_ruby,&#8230; but thanks to Phusion Passenger the configuration and deployment of RoR applications has become an easy job. I will describe how to configure Ruby on Rails with Phusion Passenger on a Debian (Debian [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dimitri.eu/configure-ruby-on-rails-with-phusion-passenger-mod_rails/"><img class="alignright size-full wp-image-217" title="rails" src="http://www.dimitri.eu/wp-content/uploads/2010/07/rails.png" alt="rails" width="87" height="111" /></a>The configuration of a new Ruby on Rails (RoR) environment has always been a bit of a struggle thanks to mongrel, mod_ruby,&#8230; but thanks to Phusion Passenger the configuration and deployment of RoR applications has become an easy job.</p>
<p>I will describe how to configure Ruby on Rails with Phusion Passenger on a Debian (Debian GNU/Linux 5.0.4 (lenny)) server.</p>
<p><span id="more-169"></span></p>
<p><strong>1. We start by resynchronizing the package index files with their sources </strong></p>
<pre class="brush:bash; gutter: false; toolbar:false"># apt-get update</pre>
<p><strong>2. Then we check if MySQL is installed </strong></p>
<pre class="brush:bash; gutter: false; toolbar:false"># mysql -V
mysql  Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (x86_64) using readline 5.2</pre>
<p>You should run the following command if MySQL isn&#8217;t installed</p>
<pre class="brush:bash; gutter: false; toolbar:false"># apt-get install mysql-server-5.0</pre>
<p>Please choose a secure MySQL root password when this question is asked by the MySQL installer</p>
<p><strong>3. We can now start by installing ruby </strong></p>
<pre class="brush:bash; gutter: false; toolbar:false"># apt-get install ruby irb rdoc</pre>
<p>These 3 packages will be configured automatically on your server so no further configuration is required. After the installation of these packages you should be able to run the ruby-command</p>
<pre class="brush:bash; gutter: false; toolbar:false"># ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]</pre>
<p><strong>4. We now need to install the rubygems module</strong>. Gems is the package manager for ruby which gives the users an easy way to install additional ruby modules.There are 2 methods to install gems onto your system. There is the apt-get method, and there is the manual one. We could use apt-get to install gems but this has a limitation, you won&#8217;t be able to update your ruby configuration using</p>
<pre class="brush:bash; gutter: false; toolbar:false"># gem update --system</pre>
<p>So we choose the manual method to install gems. Don&#8217;t copy the next link before you have checked the rubyforge.org website for the most recent version of rubygems.</p>
<pre class="brush:bash; gutter: false; toolbar:false; auto-links:false"># cd /usr/src
# wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
# tar -xvzf rubygems-1.3.7.tgz
# cd rubygems-1.3.7
# ruby setup.rb
RubyGems 1.3.7 installed

ï»¿=== 1.3.7 / 2010-05-13

NOTE:
...
New features:
...
Bug fixes:
...
RubyGems installed the following executables:
        /usr/bin/gem1.8</pre>
<p>Now for the ease of use we will create a link to run the binary gem1.8 as the command gem.</p>
<p># ln -s /usr/bin/gem1.8 /usr/bin/gem # gem -v 1.3.7</p>
<p><strong>5. We will now move on to the installation of Rails</strong>, this component can be easily installed by launching the following command</p>
<pre class="brush:bash; gutter: false; toolbar:false"># gem install rails</pre>
<p>It can take several minutes before you will see any output but you just have to be patient.</p>
<pre class="brush:bash; gutter: false; toolbar:false">Successfully installed rake-0.8.7
Successfully installed activesupport-2.3.8
Successfully installed activerecord-2.3.8
Successfully installed rack-1.1.0
Successfully installed actionpack-2.3.8
Successfully installed actionmailer-2.3.8
Successfully installed activeresource-2.3.8
Successfully installed rails-2.3.8
8 gems installed
Installing ri documentation for rake-0.8.7...
Installing ri documentation for activesupport-2.3.8...
Installing ri documentation for activerecord-2.3.8...
Installing ri documentation for rack-1.1.0...
Installing ri documentation for actionpack-2.3.8...
Installing ri documentation for actionmailer-2.3.8...
Installing ri documentation for activeresource-2.3.8...
Installing ri documentation for rails-2.3.8...
Installing RDoc documentation for rake-0.8.7...
Installing RDoc documentation for activesupport-2.3.8...
Installing RDoc documentation for activerecord-2.3.8...
Installing RDoc documentation for rack-1.1.0...
Installing RDoc documentation for actionpack-2.3.8...
Installing RDoc documentation for actionmailer-2.3.8...
Installing RDoc documentation for activeresource-2.3.8...
Installing RDoc documentation for rails-2.3.8...</pre>
<p>We can now check if rails was installed succesfully.</p>
<pre class="brush:bash; gutter: false; toolbar:false"># rails -v
Rails 2.3.8
</pre>
<p><strong>6. It is now time to test by creating a rails application. </strong>My webroot is configured under /var/www so I&#8217;ll use this in my test but you should verify your webroot before following these steps.</p>
<pre class="brush:bash; gutter: false; toolbar:false"># cd /var/www
# rails hello
# cd hello
# script/server
</pre>
<p>This will result in the following output</p>
<pre class="brush:bash; gutter: false; toolbar:false; auto-links:false">=&gt; Booting WEBrick
=&gt; Rails 2.3.8 application starting on http://0.0.0.0:3000
/usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:271:in `require_frameworks': no such file to load -- net/https (RuntimeError)
</pre>
<p>We get this error because the ruby openssl library is required so we install this.</p>
<pre class="brush:bash; gutter: false; toolbar:false; auto-links:false"># apt-get install libopenssl-ruby
# script/server -d
=&gt; Booting WEBrick
=&gt; Rails 2.3.8 application starting on http://0.0.0.0:3000
</pre>
<p>The &#8220;-d&#8221; parameter starts rails and detaches the process so that you can continue working within your shell.</p>
<p>7. <strong> We can now move on to installing Phusion Passenger</strong> (mod_rails) as the configuration of Ruby and Rails has succeeded.</p>
<pre class="brush:bash; gutter: false; toolbar:false"># apt-get install ruby-dev
# gem install passenger
# passenger-config --version
2.2.15
</pre>
<p>We now need to configure the Passenger apache module, this can be done by the following command. You&#8217;ll probably get some errors that certain modules are missing but you can easily install them to comply with the Passenger requirements.</p>
<pre class="brush:bash; gutter: false; toolbar:false"># passenger-install-apache2-module
The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /usr/bin/ruby1.8

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

Press ENTER to continue.
</pre>
<p>Check if your apache config (mine is /etc/apache2/apache2.conf) has the line <em>/etc/apache2/mods-enabled/*.load.</em> If not you can just add this line to your apache config.</p>
<p><strong>8. We will now create the apache Passenger module and activate it.</strong></p>
<pre class="brush:bash; gutter: false; toolbar:false"># cd /etc/apache2/mods-available/
# touch passenger.load
# vi passenger.load
</pre>
<p>enter the following lines and save the file.</p>
<pre class="brush:bash; gutter: false; toolbar:false">LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /usr/bin/ruby1.8

# ln -s ../mods-available/passenger.load passenger.load
# /etc/init.d/apache2 restart
# a2enmod</pre>
<p>You can now find &#8220;passenger&#8221; in this list so just type &#8220;passenger&#8221; and press enter to activate this apache module. Now restart apache.</p>
<pre class="brush:bash; gutter: false; toolbar:false"># /etc/init.d/apache2 restart</pre>
<p><strong>9. The final step is to let apache know where to find your app.</strong> Therefore you need to modify the apache configuration file of the vhost that will run your app, for example /etc/apache2/sites-enabled/000-default. Following this manual the following lines need to be configured in this config file:</p>
<pre class="brush:bash; gutter: false; toolbar:false">DocumentRoot /var/www/hello/public
PassengerAppRoot /var/www/hello/
</pre>
<p><strong>10. You now have a working Ruby on Rails environment with Phusion Passenger.</strong> If you want more information about Phusion Passenger there is always the user guide at <a title="Mod_rails user guide" href="http://www.modrails.com/documentation/Users%20guide%20Apache.html" target="_blank">http://www.modrails.com/documentation/Users%20guide%20Apache.html</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimitri.eu/configure-ruby-on-rails-with-phusion-passenger-mod_rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

