Deploying a Rails Application With Passenger
From OCS Support Wiki
Contents |
Introduction
This guide will show you how to deploy your Rails application with mod_rails on our cPanel and Webmin. This is by far the easiest way to deploy your Rails application, and is now the recommended method of deployment.
cPanel
Upload Your Existing Application
To use an existing Rails application with mod_passenger on our cPanel servers, simply upload it to a directory in your home directory (we recommend rails_apps/yourapp, where yourapp is a short name for your application). You will also need to setup your database settings if you have not already done so.
Setting the PassengerAppRoot
In the public folder of your Rails app, create a blank .htaccess file and put the following line, replacing user with your cPanel/FTP/SSH username, and rails_apps/yourapp with the location you have deployed your Rails app to.
PassengerAppRoot /home/user/rails_apps/yourapp
Symlinking the Public Folder
If you want your Rails application to be on your main site (that is, when you go to yoursite.com, you get your Rails app), then run via SSH:
cd ~ mv public_html original_public_html ln -s ~/rails_apps/yourapp/public public_html
Replace rails_apps/yourapp with the path to your Rails application.
Deploying to a Sub Folder
If you want to have your Rails application hosted from a sub-folder on your site, like www.yoursite.com/myrails instead of your main site, you'll need to run via SSH:
cd ~ mkdir -p public_html ln -s ~/rails_apps/yourapp/public public_html/myrails cd ~/public_html
Replace yourapp with the correct name of your application and myrails with the sub folder you want to have host your Rails application.
Webmin
Upload Your Existing Application
To use an existing Rails application with mod_rails on our Webmin servers, simply upload it to a folder in your home directory (not in the public_html folder on the server though). You will also need to setup your database settings if you have not already done so. This guide does not cover this section.
Changing the Document Root
Changing the document root is probably the simplest way to activate mod_rails for your Rails application.
In Webmin, click on Configure Website under Services as shown below:
Click on Document Options and then click the browse icon on the document options form, as shown below:
Select the public folder from your Rails application. In our example above, this would be in the myapp/public folder.
Click Save, then Apply Changes in the top right-hand corner of the page.
Your Rails application should now work correctly.
Using a symlink
You can also use a symlink to link the existing public_html folder, which is there by default, to another area. This is a more advanced method. You can do something similar to:
cd ~ mv public_html original_public_html ln -s myapp/public public_html
to achieve the symlink. If in doubt, use the changing document root method above.


