OCS Solutions Web Hosting Design and Consulting Web Hosting and Consulting Call Us
OCS Home  |  Wiki Front Page  |  Web Hosting  |  Virtual Dedicated Servers  |  Consulting  |  Support  |  Contact Us

Starting Your Rails Application with Mongrel

From OCS Support Wiki

Jump to: navigation, search

Contents

Important Notice

These instructions are here for the rare application that cannot work with Passenger. We recommend that nearly all of our clients use the Deploying a Rails Application With Passenger instead of this guide.

Introduction

Mongrel is a high performance, lightweight HTTP server that works great for serving Ruby on Rails applications. It is now recommended over Lighttpd as it consumes less memory and tends to scale better.

Preparation

You will need a port for Mongrel to listen on. If you haven't done so already, please see the guide on Requesting_a_Mongrel_or_Lighttpd_Port. The port typically starts with 60, like 60040, for example.

Before starting Mongrel, you need to be sure your config/database.yml file is configured properly and your database migrated (using rake db:migrate or manually if you prefer).

Running Mongrel

Make an SSH connection to your account and change into the folder your Rails application is. For the purposes of this example we are going to use ~/rails_sites/myapp, where ~ represents your home directory in Linux (so essentially, this full path is /home/you/rails_sites/myapp, where you is your Webmin/FTP/SSH username. Run the following commands:

cd ~/rails_sites/myapp
mongrel_rails start -e production -p 60000 -d

Replace 60000 with the port you are assigned. Do NOT copy and paste this example and run it as is, as it will require modification of both your path to your Rails app and the port number.

Your Rails app should start up. Now go to http://yoursite.com:60000 (where yoursite.com is your website, and 60000 is the port you are assigned) and you should see your Rails application. If you have not yet transfered your website to us, you can use http://servername:60000, where servername is the name of the server from your welcome letter (for example, if you were on the Zeus webmin server, your URL would be http://zeus.ocssolutions.com:60000).

Setting Up a Proxy For Your Site

You probably don't want to reference your site by port number for anything other than testing.

To have your website go to your Rails app without the port number, you'll need to enable Apache's proxy feature. Please see How to Proxy Your Mongrel to Your Website for instructions on how to do this.

Starting Your Application on Reboot

Once you have your Mongrel instance running, you'll want to make sure it gets started again if the server has to reboot. To do this, see the guide Starting Your Application At Boot.

Troubleshooting

If you are having trouble getting your Mongrel instance to start, see the guide Troubleshooting a Ruby on Rails Application.

Personal tools