Mongrel

POSSIBLE OUTDATED INFORMATION!
DreamHost does not directly support any of the features described on this page and is not responsible for keeping this content updated or accurate. Use at your own risk!

 

As of February 4, 2008, DreamHost officially supports the Mongrel application server on all DreamHost VPS and DreamHost Dedicated servers. If you have one of these hosting plans, you can visit the Mongrel and Proxy section of the web panel for setup options.

Mongrel and Passenger provide much of the same functionality so you most likely do NOT want to use both of them on the same website.

Getting Started

  1. Upload your working application.
  2. Configure your Mongrel server from the Mongrel and Proxy section of the web panel.

Within a few minutes, your application will be up and running on Mongrel.

Restarting Mongrel

Once you create a Mongrel application server, you must restart it any time you change your application code. Unlike FastCGI, Mongrel does not automatically restart. To do this you must connect to the server via SSH, cd to the application directory, and then run one of the following commands:

[server]$ ./mongrel-restart
[server]$ ./mongrel-start
[server]$ ./mongrel-stop

Tips

It may take some time to figure out how to properly configure the Mongrel server and Rails application. The following are a few suggested steps to help you set up a Mongrel server:

  1. Create the directory my_dir in your web account. If the directory does not exist, then the mongrel-start and -stop apps don't appear in the directory.
  2. Copy the rails application code to the directory, with the config and public appearing in the my_dir directory.
  3. Go to the panel and use the form to specify the directory http/my_dir from the root of the user's account and the URL for the application "www.example.com/my_rails_app" or leave blank for "www.example.com" to be proxied to the rails port. Although this is automatically done, there is not explanation that this is what is happening.
  4. After the proxy is set up (and the information appears in the Mongrel list, and the port number is listed), then SSH back into your site and you should find "mongrel-start, mongrel-stop, and mongrel-restart" applications copied into your "my_dir" directory.
  5. Run mongrel-start from the command line.
  6. Visit "www.example.com:300X" where 300X is your mongrel port. This should connect directly to your rails application which is already running via Mongrel. If you have not executed "mongrel-start" from the command line, you should see an error message.
  7. Test that "www.example.com/my_rails_app" properly connects and proxies to your rails application (or, "www.example.com" if you want the root to work).

If you do not create the directory properly, you may see only the following:

[server]$ mongrel_rails start | stop | restart

Advanced options

If you would like more control over the proxy setup of your Mongrel application, you can delete the proxy server automatically created when you created your Mongrel application, and then use mod_rewrite to proxy specific requests. You may want to do this if you have a lot of static files so those can be processed by Apache instead of passed to Mongrel.

See also