Skip to content

Instantly share code, notes, and snippets.

@dwayne
Last active March 9, 2020 10:01
Show Gist options
  • Save dwayne/6713632 to your computer and use it in GitHub Desktop.
Save dwayne/6713632 to your computer and use it in GitHub Desktop.
How to install Ruby on Rails + MySQL + Apache with Passenger on Ubuntu

Introduction

This guide currently uses Ruby 1.9.3, Rails 3.2 and Ubuntu 13.04 (Raring Ringtail). I started off with a fresh install of Ubuntu on a virtual machine.

Step 1: Install Ruby

  1. Install RVM. See http://rvm.io/rvm/install for all the details.

     $ sudo apt-get install curl
     $ \curl -L https://get.rvm.io | bash -s stable
    

    IMPORTANT: Add the following to ~/.bashrc.

     # Load RVM into a shell session *as a function*
     [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
    

    Open a new terminal and verify that type rvm | head -n 1 returns rvm is a function.

  2. Install Ruby 1.9.3.

     $ rvm install 1.9.3
    

Step 2: Install MySQL

$ sudo apt-get install mysql-server libmysqlclient-dev

NOTE: The libmysqlclient-dev library is needed when it's time to run gem install mysql2.

References:

Step 3: Install Apache2 Web Server

$ sudo apt-get install apache2

References:

Step 4: Install Phusion Passenger

$ gem install passenger

Loosen your permissions

$ passenger-config --root

Suppose that the above command outputs /home/username/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.19. Then you chmod o+x the directory itself and all parent directories up until /home/username.

$ chmod o+x /home/username/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.19
$ chmod o+x /home/username/.rvm/gems/ruby-1.9.3-p448/gems
$ chmod o+x /home/username/.rvm/gems/ruby-1.9.3-p448
$ chmod o+x /home/username/.rvm/gems
$ chmod o+x /home/username/.rvm
$ chmod o+x /home/username

Run the Phusion Passenger installer and follow the on-screen instructions.

$ passenger-install-apache2-module

At the end of the installation process, you will be asked to copy and paste a configuration snippet (containing LoadModule, PassengerRoot, etc.) into your Apache configuration file.

Restart your web server and run passenger-memory-stats.

$ sudo service apache2 restart
$ passenger-memory-stats

You should see the web server processes as well as a number of Phusion Passenger processes (e.g. PassengerWatchdog, PassengerHelperAgent). Congratulations, Phusion Passenger is now installed and running!

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment