Thomas Mullaly

DevOps, Security and IT Leadership

Rails Production Server

Load Ubuntu 12.04

Get updates. Run ‘sudo apt-get update’ and ‘sudo apt-get upgrade’ and ‘sudo apt-get dist-upgrade’


Install Apache2

sudo apt-get install apache2

Install curl

sudo apt-get install curl

Install rvm (Multi-User install)

curl -L | sudo bash -s stable

Install Ruby Dependencies:

apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

Install the latest version of ruby

rvm install ruby

Install the rails gems

gem install rails

Install The Ruby Racer

gem install therubyracer

Install nodejs

apt-get install nodejs

Get ready for passenger

apt-get install libcurl4-openssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
gem install passenger

Install the passenger module


Edit your Apache configuration file, and add these lines:

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/ext/apache2/
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby

Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your Apache configuration file and set its DocumentRoot to /somewhere/public:

<VirtualHost *:80>
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public    
      <Directory /somewhere/public>
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews

And that’s it! You may also want to check the Users Guide for security and optimization tips, troubleshooting and other useful information:

/usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/doc/Users guide Apache.html

Add deploy user and add rvm group

useradd deploy -d /home/deploy -m deploy
passwd deploy
usermod -a -G rvm deploy