Using Phusion Passenger on Rails Machine
Phusion Passenger, or mod_rails/mod_rack, is an Apache module that greatly simplifies Ruby web application deployment. Before you can start using Phusion Passenger you will need to install a few items on your existing Rails Machine virtual private server. This guide will walk you through the preparation of your Rails Machine, the installation of Phusion Passenger, and the conversion of your existing application to use Phusion Passenger.
Upgrading Ruby Gems
If you are using a version of Ruby Gems before the 1.2 version release on your server you will need to upgrade to avoid complications during the install.
Install Phusion Passenger and Ruby Enterprise Edition
Execute the following commands from your deploy user account on your Rails Machine.
# make a place to do the install
mkdir passenger_install
cd passenger_install
# download and start the installer
wget http://assets.railsmachine.com/wiki/centos_passenger_install.sh
sh centos_passenger_install.sh
Optional: Using Ruby Enterprise Edition
Ruby Enterprise Edition comes with a set of pre-installed gems. You will need to install the gems that are missing from Ruby Enterprise Edition’s line up. You must specify the path to Enterprise Ruby as it is not in your path. After you are done installing your gems, modify the /etc/httpd/conf.d/passenger.conf to use Ruby Enterprise Edition.
# re-install all of your regular-Ruby gems with Enterprise Ruby
gem list | grep -v passenger | awk ' (NR != 1 && NR != 2 ) {print $1}' | xargs sudo /opt/ree/bin/gem install --no-ri --no-rdoc
sudo /opt/ree/bin/gem install mysql -- --with-mysql-config
# change /etc/httpd/conf.d/passenger.conf to use Enterprise Ruby
#LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/passenger-2.2.8/ext/apache2/mod_passenger.so
#PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-2.2.8
#PassengerRuby /usr/bin/ruby
# Ruby Enterprise Edition settings
LoadModule passenger_module /opt/ree/lib/ruby/gems/1.8/gems/passenger-2.2.8/ext/apache2/mod_passenger.so
PassengerRoot /opt/ree/lib/ruby/gems/1.8/gems/passenger-2.2.48
PassengerRuby /opt/ree/bin/ruby
Restart Apache
#restart apache
sudo /etc/init.d/httpd restart
# Check to see that Passenger loaded successfully
sudo /usr/sbin/apachectl -t -D DUMP_MODULES 2>&1 | grep passenger
# If it wasn’t listed in the step above, make sure that /etc/httpd/conf/httpd.conf contains this line:
Include conf.d/*.conf
Capistrano and Passenger
The following steps should be performed on your local development machine not on your Rails Machine.
# install lastest railsmachine gem (on your local machine)
sudo gem install railsmachine
# add :app_server option to your deploy.rb
set :app_server, :passenger
# switch to Passenger
cap app:switch
