Phusion Passenger (a.k.a mod_rails) is an open-source Apache module that makes deploying rails apps as easy as falling off a log. Its got cool features like deploying multiple rails applications on a single server and is pretty well documented.
This guide aims to get your basic rails application up and running on a linux box (Ubuntu) though other distro’s would work all the same only that some packages or configuration files might be named differently. A name-based virtualhost allows you to assign different hostnames to one IP address. See differences with IP-based virtualhosts here . Note: Dont take my word that this will work, I did this quite a while back and was lazy to write this post then.
- Install the Passenger gem. Passenger is available as a gem though you can also install it from source but installing it as a gem works just fine.
- After installing the gem install the apache2 module for rails which will guide you through a very user-friendly step by step guide. The module requires a few dependencies which the installer will show you how to install them.After the installation the installer will show you how to modify the apache configuration file. Copy the text to a text file
- Open your httpd.conf file (located in /etc/apache2/httpd.conf on ubuntu and /etc/httpd/conf/httpd.conf on RedHat Enterprise 5) and add the following lines. Note that the lines varies depending on your system, what I have would probably be different from what you have.
- Then we need to tell apache to listen for all defined virtualhosts requests.
- We can then configure as many name-based virtualhost configurations as we want on the same file. Here’s a sample virtualhost configuration
- Then restart apache ubuntu:
$ sudo /etc/init.d/apache2 restartredhat:
$ service httpd restart
- Then you should be able to access your rails app from the URL http://domain.example.com assuming that you already have a DNS server map this URL to your server, otherwise you will have to edit your /etc/hosts file and map domain.example.com to your server.
$ sudo gem install passenger
$ sudo passenger-install-apache2-module
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
Options Indexes FollowSymLinks MultiViews
allow from all