skip navigation

Rails 3 on Apache on Ubuntu 10.04

Robert Gauld

So I was investigating how to run a rails app on my VPS. I needed to use several sources to get little bit's working, so here's the combined instructions. Note that I assume you're starting with a working apache installation.

On The Server (Once)

  1. Create a user for the passenger software:
    1. sudo adduser passenger
    2. sudo usermod -G passenger,www-data,sudo passenger
  2. Initial setup of passenger user and installation of RVM and gems
    1. su - passenger
    2. add this to the bottom of .bashrc
      1. nano -w ~/.bashrc
      2. [[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
      3. ctrl-o to save and ctrl-x to exit
      4. exit
      5. su - passenger
    3. sudo apt-get install openssl curl git-core subversion autoconf build-essential bison zlib1g zlib1g-dev libssl-dev libxml2-dev libreadline5 libreadline-dev libreadline6-dev libsqlite3-0 libsqlite3-dev sqlite3
    4. bash < <( curl )
    5. rvm install 1.9.2
    6. rvm use --default 1.9.2
    7. rvm 1.9.2 --passenger
    8. gem install passenger
    9. rvmsudo /home/passenger/.rvm/gems/ruby-1.9.2-p0/bin/passenger-install-apache2-module
    10. sudo apt-get install apache2-prefork-dev libapr1-dev libaprutil1-dev
    11. exit
  3. Remove user from sudo group
    1. sudo usermod -G passenger,www-data passenger
  4. Configure apache
    1. create /etc/apache2/mods-availible/passenger-rvm.load to contai
      LoadModule passenger_module /home/passenger/.rvm/gems/ruby-1.9.2-p0/gems/passenger-2.2.15/ext/apache2/
    2. create /etc/apache2/mods-availible/passenger-rvm.conf to contain:
      PassengerRoot /home/passenger/.rvm/gems/ruby-1.9.2-p0/gems/passenger-2.2.15
      PassengerRuby /home/passenger/.rvm/bin/passenger_ruby
    3. sudo a2enmod passenger
    4. sudo /etc/init.d/apache2 restart

On Your Development Machine (Once)

  1. gem install capistrano

For Each Application

  • On The Client:
    • First Deployment:
      1. cd <Application_Directory>
      2. capify .
      3. edit config/deploy.rb
      4. cap deploy:setup
    • Subsequent Deployment:
      1. cap deploy:migrations (if database migrations)
      2. cap deploy
  • On The Server
    1. Point apache to the public directory of the app:
      • For a directory of an existing site use:
        RailsBaeURI <URL to public folder of app>
      • For a (sub)domain use:
        DocumentRoot <URL to public folder of app>