Vladimir's Tech Blog

Multiple Rails applications with mod_rails on Ubuntu

April 30, 2008

It works as advertised!

The installer provides exhaustive built-in documentation, describes every step and suggests solution for every unmet requirement like “please install Apache headers with apt-get install apache2-prefork-dev”. Other guys and we all can learn a lot from mod_rails about how a perfect installer looks like.

At the end of the installation process it asks to put three configuration lines into apache configuration file although it does not tell how. According to online documentation the requirement is that these lines should be only executed once.

So my solution (in Debian way) is to

Then I followed the documentation. But I had to make an additional change to enable the FollowSymLinks.

It was also not clear from the documentation how to set up multiple applications to the same VirtualHost and that RailsBaseURI is allowed multiple times. So I had to experiment. Here is the result (works on Ubuntu 7.10):

<VirtualHost *:80>
  ServerAdmin [email protected]
    DocumentRoot /home/passenger
    RailsBaseURI /app1
    RailsBaseURI /app2
    <Directory /home/passenger>
      AllowOverride All

Then for every additional application you need to

  • copy your application to some folder, e.g. /home/myprojects/app2
  • set owner for your project folder to www-data:www-data
  • create a link from public folder of your rails application to /home/passenger
  • add one line to your site configuration RailsBaseURI /app2
  • restart apache

I did not find any way to avoid last two tasks. Hopefully the next version of passenger will offer some sort of wildcard-based mass-RailsBaseURI.

Current mod_proxy advantages:

  • no ActionController::AbstractRequest.relative_url_root requierd anymore
  • no obscure mod_proxy_html
  • SSL is now possible for multiple Rails applications on the same server (VirtualHosts on the same IP address do not work with SSL)


  • did not have time yet to configure with capistrano, simply checked in the file `tmp/restart.txt’. Every time I do ‘svn update’, the application is automatically restarted.
Powered by Movable Type 3.31