Following from the first article, we now have passenger (mod_rails) installed.
As such, we can move on and create a Ruby on Rails application and see how easy it is to serve using passenger.
As the default permissions only allow us, the 'demo' user, to browse our home folder, let's start off by giving Apache access to this folder as well:
chmod 755 /home/demo
Move into the public_html folder (if you don't have one, then simply create it):
Then create a simple Ruby on Rails application:
To serve the Rails application, we need to create a virtual host:
sudo nano /etc/httpd/conf/httpd.conf
Although already mentioned, one of the exciting things about mod_rails is that you don't need any special settings in the virtual host configuration.
The contents can be as simple as this:
<VirtualHost *:80> ServerName domain1.com ServerAlias www.domain1.com DocumentRoot /home/demo/public_html/testapp/public </VirtualHost>
Of course, you can add custom log file locations and other settings but the main thing to understand is the lack of proxy and port settings.
Finally, we need to enable the new site by reloading Apache:
sudo /etc/init.d/httpd reload
Note: If you get any port and NameVirtualHost errors on reloading Apache, please ensure you read the Apache Virtual Hosts article.
Is that it?
Yup. It really is that simple to serve Ruby on Rails applications with passenger (mod_rails).
Additional Rails apps can be configured in the same way - create a vhost and it's done.
Changes to the application
Whenever you deploy changes to your application all you need to do is:
That will enable the new content to be served - the command can be used in Capistrano or any script you use to deploy your applications.
Phusion's passenger (mod_rails) is easy to install and even easier to use.
There are no ports or proxies or any other complicated configurations.
As you can see, mod_rails offers a great deal to the Ruby on Rails community.