Nicolas Alpi, Web developer

A blog about productivity, startups and me.

How to Install Passenger for Ruby on Rails on an Apache2 / Linux Box

I was preparing the future of this blog, and for that I need to have a sandbox ready for the development and the production.

I decided to give a test to Passenger (aka modRails) for the apache2 Ruby on Rails integration. It’s amazing how simple it is to have a Rails application working now …

What’s Passenger ?

Passenger is a server side module, which enables to have a rails application working without any configuration. People use to say that, with Passenger, you’ll be able to deploy Rails application like PHP application.

Also, and because it made the creation of virtual host very easy, Passenger is looking as the solution for more Rails shared host providers.**

How to install Passenger (on an Ubuntu Server Box) :**

I assume that you have your Rails and Apache2 installed.

First we need to install the apache2-dev libs

  • sudo apt-get install apache2-prefork-dev
Then we are going to install the gem for passenger and passenger apache himself.

  • sudo gem install passenger
  • sudo passenger-install-apache2-module
For me the version of passenger was 2.0.3, I just follow what the installer said :

copy in /etc/apache2/apache2.conf

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

__Be sure that the rewrite mode is enabled :

  • sudo a2emod rewrite
Create a vhost file in /etc/apaches/sites-available/myRailsApp.com

and put inside something like

ServerName myRailsApp.com DocumentRoot /path/to/myRailsApp/public/

And restart now apache (sudo /etc/init.d/apache2 restart), and you should have a passenger box working.

**And now ?

**Now you just have to upload the new files to have your application working with Passenger.

I’ll use it for my sandbox, and have some test on the performance before using it on my future web application.

The next step will be to have capistrano 2 working with this configuration. It should be easy, we’ll see that this week ;)

Comments