Pushing your app to the real world with Rails can be a very daunting task to someone who is used to just uploading flat html or php files.
If you’ve never dealt with Apache, mod_rewrite, or proxy servers, prepare to spend a lot of time hammering out a solution. Worried about performance, or your need to scale out at a later date? Pick a solution that won’t leave you wondering if your site will be able to take a spike in traffic.
For Rails, there are lots of deployment strategies, some are tuned for compatibility with shared hosting (fastcgi), and some are built for speed and minimum configuration (Litespeed Nginx and Lighttpd), and some are built to leverage the strength and flexibility of stable and established server software (Apache+Mongrel).
If you want to scale, you’re going to need a load balancing proxy. The choices here are pound, pen, and apache’s mod_proxy_balancer.
An abundance of choice is a double-edged sword. Competition is good in any arena, but it makes it very hard for someone who hasn’t tried them all to choose one.
I’ve chosen to setup my Rails server using the Apache+Mongrel+mod_proxy_balancer combination.
For the operating system, I’ve chosen the newest Ubuntu 7.10 (Gusty) server. Ubuntu uses the Debian-style apt package management, but with more current packages than Debian stable, and is the current cool kid on the block for Linux systems. I have been using Ubuntu for years and can attest to its stability and cutting edge (but not bleeding edge) packages.
I’ve gone through and built a Rails server by hand before, but poorly documenting what I had done, and not securing it properly. When I stumbled upon Slicehost’s server setup articles, I knew I had found exactly what I needed to build a server configured like a pro, and all the documentation I should have written in the first place.
Here is the step-by-step setup for a production Rails server. I’ve tested this setup and can vouch for its awesomeness. I encourage you to make some changes specific to your setup where appropriate. You should be able to skip unneccesary stuff like php and virtual hosts if you don’t need them.
Ubunty Setup – part 1
Ubunty Setup – part 2
Myql and Rails
Apache and PHP
Apache Virtual Hosts
Vhosts and permissions
Apache Vhosts, Rails and Mongrels
Mongrel Clustering
Subversion intro
Setting up svnserve
Securing svnserve with ssh
Setting up Capistrano
Setting up Piston to manage plugins
As you can see, most of these are from Slicehost’s documentation articles. They also detail setup for several other major linux distributions and other deployment strategies like nginx. Major props to slicehost for putting such excellent documentation together.


Thanks for the write up. I too set mine up manually and took (sketchy) notes. There are a few things I missed too, so will go through and make sure I’ve covered everything.
[...] Unixmonkey.net » Blog Archive » Setting up a production rails server step-by-step (tags: rails deployment rubyonrails production mongrel apache ruby server **) [...]
[...] Unixmonkey.net » Blog Archive » Setting up a production rails server step-by-step Nice tutorial on setting up a production Rails environment. (tags: rubyonrails tutorial setup) [...]
Question: if I were to follow these instructions, how much knowledge and upkeep would be required to keep a rails app running on it? I’m trying to figure out the best way to host rails for someone without a lot of technical experience and not an abundance of time to spend figuring it all out.
Any suggestions?
[...] Setting up a production rails server step-by-step [...]
Paul Sullivan:
I don’t know how comfortable you are doing server admin type stuff, but provided you stay on top of security stuff, this kind of setup should run without issue for a good long time. You might want to use more than 2 mongrels for anything getting more than casual traffic. The slicehost documentation carefully explains everything you are doing, so it should be pretty self-explanatory what you need to keep an eye on.
Add on monit for scripting notification emails or for restarting mongrels if you think you really want to set it and forget it.
[...] Unixmonkey.net have published a step by step article on setting up Ruby on Rails on a production server. Should work for VPS too. Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages. [...]
Story added
Your story was featured in wscoop! Post: http://www.wscoop.com/Hardware/Setting-up-a-production-rails-server-step-by-step
Not to pimp my own wares but you should check out elastic server – http://es.cohesiveft.com – it’s something we’ve been working on to let you build ready to go virtual servers (vmware, xen, amazon ec2) in just a couple clicks with whatever you want on it. We have some ready to go RoR packages (although they’re not yet up to date with the latest and greatest).
You can build and launch the server on ec2 right away and use its built in patching capabilities to make auto updates to the server. It’s private beta right now but if you’re interested click the signup code link on the front page and we’ll get you in!
The basic community edition is totally free so you can try it out
thanks