Ruby on Rails in cPanel

Recently, during a subcontract job, I had cause to use cPanel to set up Ruby on Rails for an app; the contractor I was working with was using UKHost4u who only support it via this method. After a few trials and tribulations, I managed to get a working application running through Mongrel. Now, to get it working on port 80, the cPanel method appeared to be redirecting to Mongrel through Apache. This proved more difficult than expected. After setting it up I had issues with Apache not redirecting correctly and sending files as text/plain rather than text/html as the browser required.

In cPanel, under “Ruby on Rails”, I was able to set up a link to Mongrel. This wrote a .htaccess file in public_html, redirecting all requests for the domain to the domain with the port number. However, according to this Stack Overflow question, a bug in Mongrel (described in lighthouse) prevents this method from working out of the box. Adding this file into your config/initializers folder should patch the problem; add it in and restart Rails.