13 Jan
by: Eric in Development, Infrastructure, Ruby on Rails
tags: apache, deployment, passenger, phusion, ruby, ruby enterprise edition, Ruby on Rails
I've been using Phusion Passenger for a few months now and I'm really pleased with it. The performace vs. Mongrel is better, but what makes it so useful is the ease of deployment. Being able to setup a vhost in Apache just like you would for a PHP application was very appealing to me. Having previously worked with the Apache/Rails/Mongrel/mod_proxy stack in an "enterprise" environment for over a year, I have experienced pretty much every nightmare deployment scenario possible. I recently decided to install Phusion's Ruby Enterprise Edition, which promises up to a 33% savings in memory usage.
Before you do anything, and to save you trouble down the road, I recommend generating a list of all the gems currently installed. You'll need this later because you'll have to reinstall all of them in Ruby Enterprise Edition.
$ gem list
*** LOCAL GEMS ***
actionmailer (2.0.2)
actionpack (2.0.2)
activerecord (2.0.2)
activeresource (2.0.2)
activesupport (2.0.2)
acts_as_taggable (2.0.2)
amazon-ecs (0.5.3)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
fastthread (1.0.1)
gem_plugin (0.2.3)
hpricot (0.6)
mongrel (1.1.4)
mysql (2.7)
passenger (1.0.1)
rails (2.0.2)
rake (0.8.1)
rspec (1.1.3)
will_paginate (2.2.2)
xml-simple (1.0.11)
Copy your list and save it somewhere. Next, we download and extract the current version of Ruby Enterprise Edition. The latest version number can be found at the download page.
$ wget http://rubyforge.org/frs/download.php/48623/ruby-enterprise-1.8.6-20081215.tar.gz
$ tar xzvf ruby-enterprise-1.8.6-20081215.tar.gz
And run the installer
$ ./ruby-enterprise-1.8.6-20081215/installer
As the installation proceeds, you'll be prompted for an installation directory. I went with the default. When the installation is over, you should see a message like this:
Ruby Enterprise Edition is successfully installed!
If want to use Phusion Passenger (http://www.modrails.com) in combination
with Ruby Enterprise Edition, then you must reinstall Phusion Passenger against
Ruby Enterprise Edition, as follows:/opt/ruby-enterprise-1.8.6-20081215/bin/passenger-install-apache2-module
Make sure you don't forget to paste the Apache configuration directives that
the installer gives you.If you ever want to uninstall Ruby Enterprise Edition, simply remove this
directory:/opt/ruby-enterprise-1.8.6-20081215
If you have any questions, feel free to visit our website:
http://www.rubyenterpriseedition.com
Enjoy Ruby Enterprise Edition, a product of Phusion (www.phusion.nl)
I do want to use Ruby Enterprise Edition and Apache, so I immediately installed the Apache module.
$ /opt/ruby-enterprise-1.8.6-20081215/bin/passenger-install-apache2-module
You need to pay attention to the Apache directives that this installation generates, since you'll have to put them into your httpd.conf:
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /opt/ruby-enterprise-1.8.6-20081215/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise-1.8.6-20081215/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /opt/ruby-enterprise-1.8.6-20081215/bin/ruby
What that message doesn't explain is that, if you previously installed Passenger without Ruby Enterprise Edition, you need to comment out any old directives attached to that previous setup. I made that mistake the first time around.
Next you have to reinstall all the gems that you were using with old Ruby, including Rails:
/opt/ruby-enterprise-1.8.6-20081215/bin/ruby /opt/ruby-enterprise-1.8.6-20081215/bin/gem install rails --version 2.0.2
Just to prove my point, if you listed all of Enterprise Ruby's gems at this point, the list would look something like this:
$ /opt/ruby-enterprise-1.8.6-20081215/bin/ruby /opt/ruby-enterprise-1.8.6-20081215/bin/gem list
*** LOCAL GEMS ***
actionmailer (2.2.2, 2.0.2)
actionpack (2.2.2, 2.0.2)
activerecord (2.2.2, 2.0.2)
activeresource (2.2.2, 2.0.2)
activesupport (2.2.2, 2.0.2)
fastthread (1.0.1)
mysql (2.7)
passenger (2.0.6)
rack (0.9.1)
rails (2.2.2, 2.0.2)
rake (0.8.3)
None of my old gems are installed. Once Rails is installed, you need to reinstall your old gems:
$ /opt/ruby-enterprise-1.8.6-20081215/bin/ruby /opt/ruby-enterprise-1.8.6-20081215/bin/gem install will_paginate
$ /opt/ruby-enterprise-1.8.6-20081215/bin/ruby /opt/ruby-enterprise-1.8.6-20081215/bin/gem install xml-simple
$ /opt/ruby-enterprise-1.8.6-20081215/bin/ruby /opt/ruby-enterprise-1.8.6-20081215/bin/gem install hpricot
$ /opt/ruby-enterprise-1.8.6-20081215/bin/ruby /opt/ruby-enterprise-1.8.6-20081215/bin/gem install rmagick
And on and on. If you haven't used Passenger before, check out the Deployment Guide. If you have used Passenger and your Rails apps are already set up in Apache to take advantage of it's deployment procedures, simply restart Apache.
Related posts:
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.