In my original article, which you can view here, we installed Ruby on Rails 2.3 onto a production Ubuntu box. The process has changed a little so I thought I would update it. The new process for installing Rails 3.x on a production server is a little bit easier. 

 

First a note on RVM:

There is absolutely no reason a production box should run RVM. RVM’s goal is to help you run several version of ruby on a machine. Passenger, the main way apache and rails communicate, can only run one version of ruby. So having RVM installed is more overhead and more room for things to break.  Gem(set)s should be handled by Bundler.

 

A note on Bundler:

Bundler should absolutely be installed on a production box. Bundler’s main goal is to help you keep all your gems the same version between machine. Production is a machine and therefor, you should use Bundler to help keep it’s gems the same version as you developed and tested against.

 

The New Steps:

Enough notes, time to get down to business. There are some minor changes in the process. Just like before I assume you have apache installed, and I assume you already have a MySQL server somewhere. If you want to install MySQL on the production web server be my guest, but these steps do not install MySQL server, or Apache.

 

  1. sudo apt-get install git-core ruby1.8 build-essential libssl-dev ruby rdoc irb libopenssl-ruby imagemagick libmagick9-dev ruby1.8-dev libmysqlclient15-dev apache2-prefork-dev libapr1-dev postfix libaprutil1-dev libcurl4-openssl-dev #the prerequisits
  2. wget http://production.cf.rubygems.org/rubygems/rubygems–1.8.6.tgz #download rubygems adjust the version as needed
  3. tar -xzf rubygems–1.8.6.tgz && cd rubygems–1.8.6 && sudo ruby setup.rb #extract and install rubygems
  4. sudo gem1.8 install rails –no-rdoc –no-ri #install some version of rails
  5. sudo gem1.8 install passenger #install passenger
  6. sudo passenger-install-apache2-module  #follow the instructions

 

Just like before, remember to configure postfix for proper TLS support, or disable it. Setup your vhosts. Bundler keeps the proper rails version for your project. We just install a system wide version to help troubleshoot. Also you will notice I chose ruby 1.8. I feel that it is more suited to a production enviroment for now. That may change in the near future. If you prefer to install 1.9 then just change the version in step 1.

 

You can download an offline version of this article by clicking here.

Coteyr.net Programming LLC. is about one thing. Getting your project done the way you like it. Using Agile development and management techniques, we are able to get even the most complex projects done in a short time frame and on a modest budget.

Feel free to contact me via any of the methods below. My normal hours are 10am to 10pm Eastern Standard Time. In case of emergency I am available 24/7.

Email: coteyr@coteyr.net
Phone: (813) 421-4338
GTalk: coteyr@coteyr.net
Skype: coteyr
Guru: Profile