Exploring myself…

Installing phusion passenger with apache2 on Ubuntu

leave a comment »

Following is the step by step process for installing phusion passenger (mod-rails) with Apache on Ubuntu 10.04. Either you should be logged in as root or should have sudo’er privileges to proceed with the installation.

I have used rvm to manage the different versions of rubies and gem-sets.

First, apache web server has to be installed with

sudo apt-get install apache2

If there are any missing dependencies, a message will be displayed and those dependencies have to be installed before proceeding further.

Then install the passenger module. This is done on a per ruby basis instead of a per-project basis.

rvm use 1.9.2-p180
gem install passenger

Then, install the apache2 module of passenger with


Create new module files in the /etc/apache2/mods-available/ folder.


LoadModule passenger_module /home/user/.rvm/gems/ruby-1.9.2-p180/gems/


PassengerRoot /home/user/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.11
PassengerRuby /home/user/.rvm/wrappers/ruby-1.9.2-p180/ruby

With this, you can enable the module with

sudo a2enmod passenger

and disable it with

sudo a2dismod passenger

Now, we want to enable passenger; so

sudo a2enmod passenger

Then, create the virtual host for your site. Change the values for DocumentRoot, RAILS_ENV, GEM_HOME etc. as needed.


<VirtualHost *:80>
  DocumentRoot "/home/user/my_project/public"
  ServerName my_project.com
  ServerAlias www.my_project.com

  SetEnv RAILS_ENV "development"
  SetEnv GEM_HOME "/home/user/.rvm/gems/ruby-1.9.2-p180@my_project"
  SetEnv GEM_PATH "/home/user/.rvm/gems/ruby-1.9.2-p180@my_project:/home/user/.rvm/gems/ruby-1.9.2-p180@global"
  SetEnv BUNDLE_PATH "/home/user/.rvm/gems/ruby-1.9.2-p180@my_project"

  ErrorLog /var/log/apache2/my_project_error.log
  LogLevel warn
  CustomLog /var/log/apache2/my_project_access.log combined

Enable the site:

sudo a2ensite my_project

Restart apache to load the passenger module and the new virtual host.

sudo /etc/init.d/apache2 restart

That should get everything up and running.

This has worked on the following software versions:
Ubuntu 10.04
Apache 2.2.14
Passenger 3.0.11
Ruby 1.9.2-p180
Rails 3.0.7 and Rails 3.1.13

With this setup only one version of ruby can be used. If you want/have to use multiple versions of ruby, check this .

Prior to passenger version 2.2.3 some nifty ruby coding was needed to pass the environment variables as described here . Phusion passenger has made life easier since the 2.2.3 release by allowing the assignment of environment variables in apache config files. Passenger 2.2.3 release notes


Written by srisoham

February 19, 2012 at 2:38 pm

Posted in apache, ruby-on-rails

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: