You are here: Home / Debian GNU/Linux / Servers / Apache 2 / Install the Phusion Passenger module for Apache 2 on Debian

Install the Phusion Passenger module for Apache 2 on Debian

by Pierre-Yves Landuré last modified Nov 11, 2017 09:44

Phusion Passenger allow to host Ruby On Rails Web applications on Apache 2.

This howto is tested on:

  • Debian 6.0 Squeeze
  • Debian 7.0 Wheezy

Prerequisite

This howto needs a Apache 2 HTTP server with the following script:

Installation

Installation from Debian package

This installation method is tested on:

  • Debian 6.0 Squeeze
  • Debian 7.0 Wheezy

Install the passenger module:

command apt-get install libapache2-mod-passenger

Create a configuration file for the passenger module:

echo "PassengerDefaultUser www-data" > "/etc/apache2/mods-available/passenger-user.load"

Enable the module:

command a2enmod passenger
command a2enmod passenger-user

Reload the Apache 2 configuration:

/etc/init.d/apache2 force-reload

Installation from the sources

This installation method is tested on:

  • Debian 5.0 Lenny
  • Debian 6.0 Squeeze

Install build dependencies:

command apt-get -y install ruby ruby1.8-dev build-essential make \
          apache2-prefork-dev libcurl4-openssl-dev libssl-dev zlib1g-dev \
          libapr1-dev libaprutil1-dev

Manualy install a recent version of the "rubygems" tool:

command wget "http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz" \
    --output-document="/tmp/rubygems.tgz"
command tar --directory="/tmp" -xzf "/tmp/rubygems.tgz"
command cd /tmp/rubygems-*
command ruby setup.rb

Install the Passenger software:

command gem1.8 install passenger

Install the Apache 2 passenger module:

command passenger-install-apache2-module

Create the Passenger module configuration file for Apache 2:

PASSENGER_ROOT=$(find /usr/lib/ruby/gems/1.8/gems/ -type d -name "passenger-*" \
          | command sort | command tail -n 1)
echo "LoadModule passenger_module ${PASSENGER_ROOT}/ext/apache2/mod_passenger.so" \
          > "/etc/apache2/mods-available/passenger.load"
echo "PassengerRoot ${PASSENGER_ROOT}
PassengerRuby /usr/bin/ruby1.8
PassengerDefaultUser www-data" > "/etc/apache2/mods-available/passenger.conf"

Enable the passenger module for Apache 2:

command a2enmod passenger

Usage

For the Apache 2 Passenger module to work properly, the Apache 2 virtual host configuration file of Ruby On Rails sites must contain:

Options -MultiViews

Setup with a2tools

Provide the Ruby On Rails application domain :

DOMAIN="rails.domain.com"

Provide the rails application installation path :

INSTALL_PATH="/opt/rails/${DOMAIN}"

Add the MultiViews option to the rails application .htaccess file :

command echo "# Passenger module specific options.
Options -MultiViews" >> "${INSTALL_PATH}/public/.htaccess"

Create the Apache 2 configuration with :

command a2tools --overrides="FileInfo Options=All,Multiviews" "${DOMAIN}" "${INSTALL_PATH}/public"

Reload the Apache 2 configuration:

/etc/init.d/apache2 force-reload

Thanks