Fork me on GitHub

Apache and Passenger (mod rails)

Hate deployment via FastCGI? You're not alone. But guess what, Passenger supports Rack; and this book tells you how to get it all going.

You can find additional documentation at the official modrails website.

The easiest way to get started with Passenger is via the gem.


First you will need to have Apache installed, then you can move onto installing passenger and the apache passenger module.

You have a number of options when installing phusion passenger, however the gem is likely the easiest way to get started.

gem install passenger

Once you've got that installed you can build the passenger apache module.


Follow the instructions given by the installer.

Deploying your app

Passenger lets you easily deploy Sinatra apps through the Rack interface.

There are some assumptions made about your application, however, particularly the tmp and public sub-directories of your application.

In order to fit these prerequisites, simply make sure you have the following setup:

mkdir public
mkdir tmp

The public directory is for serving static files and tmp directory is for the restart.txt application restart mechanism. is where you will place your rackup configuration.


Once you have these directories in place, you can setup your applications rackup file,

require 'rubygems'
require 'sinatra'
require File.expand_path '../app.rb', __FILE__

run Sinatra::Application

Virtual Host

Next thing you'll have to do is setup the Apache Virtual Host for your app.

<VirtualHost *:80>
    DocumentRoot /path/to/app/public
    <Directory /path/to/app/public>
        Require all granted
        Allow from all
        Options -MultiViews

That should just about do it for your basic apache and passenger configuration. For more specific information please visit the official modrails documentation.

A note about restarting the server

Once you've got everything configured it's time to restart Apache.

On most debian-based systems you should be able to:

sudo apache2ctl stop
# then
sudo apache2ctl start

To restart Apache. Check the link above for more detailed information.

In order to restart the Passenger application, all you need to do is run this simple command for your application root:

touch tmp/restart.txt

You should be up and running now with Phusion Passenger and Apache, if you run into any problems please consult the official docs.