5 March 2010 · About 1 minute read

Run Rails 3 Apps on Passenger

Update: Make sure you update Rubygems using sudo gem update --system.

Whilst I’ve been learning more about Rails 3, I’ve been using the built in rails server to run my code. Today I tried to run my Rails 3 app through Passenger on Apache, and immediately hit an error page:

textuninitialized constant Rack::Runtime

It turns out that Passenger notices Rails’ new config.ru file, causing it to run as a Rack application. This requires a slight change in the app’s VirtualHost entry. The RailsEnv setting now becomes RackEnv:

```apache# /etc/apache2/apache2.conf

RailsEnv development

RackEnv development```

But that wasn’t all. My development machine was still running Passenger 2.2.7, which wouldn’t support Rails 3. To ensure a clean slate, I removed the old versions of Passenger and installed the latest build (2.2.11 at the time of writing). Once installed, I ran the standard Passenger installation script and updated apache2.conf:

```bash$ sudo gem update –system

$ sudo gem uninstall passenger

# Remove all versions of Passenger

$ sudo gem install passenger

$ sudo passenger-install-apache2-module```

```apache# /etc/apache2/apache2.conf

Passenger mod_rails

NOTE: Your paths may be different. Use the config generated by Passenger’s install script)

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so

PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11

PassengerRuby /usr/bin/ruby1.8

RailsEnv development

RackEnv development```

After a quick restart of Apache, Passenger kicked in and my new Rails 3 app was up and running!


Learn how to keep your Rails apps fast, secure and running in top condition.

The Ruby and Rails worlds move fast, so it can feel like no time at all before your app starts to feel left behind.

Slow pages, memory, new gems, a constant stream of security patches, changing third-party APIs, and growing demands on your server's resources all work tirelessly against your app.

While your app launched with a strong foundation— the latest gems, employing best practices, and developing a thorough test suite—it needs constant attention and maintenance to keep running in top condition.

In Keep Your Ruby on Rails App Healthy, you'll learn about the tools and techniques for keeping your Ruby on Rails app running smoothly, and how to apply them to your apps.

The course delivers a range of practical and actionable lessons to enhance and protect your app right away, from simple, quick–win optimisations and setting up thorough monitoring to reviewing your site's performance, and checking your code against security vulnerabilities current best practices.

“I really enjoyed the book. A lot of quick wins for me to implement and makes me realise I can do more with guard.” –– Ben (@r0_0tKat)

Keep Your Ruby on Rails App Healthy is available as both an email course, and as a premium download edition.

The email course is split up into 7 lessons, delivered to your inbox over the course of a month.

The premium edition is available for instant download in PDF, ePub and Mobi (Kindle) format.

Start Email Course Buy Premium $9 (plus EU VAT)

rails howto programming apache passenger
Chris Blunt
Chris Blunt @cblunt
Chris is the founder of Plymouth Software. As well as code and business, he enjoys being a Dad, swimming, and the fine art of drinking tea.