Amazon EC2 setup for Ruby on Rails

7 Apr 2012

This works with Amazon EC2 with its original OS

Here is the steps:

  1. Uninstall Ruby 1.8.7
  2. Uninstall Rubygems
  3. Install Ruby 1.9.3
  4. Make a link from ruby1.9 to ruby
  5. Install Rubygems for Ruby 1.9.3
  6. Make a link from gem1.9 to gem
  7. Install aws-amitools-ec2 (No idea what is it, but it was uninstalled because of Ruby 1.8.7)
  8. Install Passenger
  9. Install Git

The current draft

Warning: sometimes Rubygems mysteriously doesn't include `/usr/local/bininto ``PATH`. This causes the commandpassenger-install-nginx-module`` to fail.

Use Root to run the script

Run it with `nohup ./ &`.

#!/bin/bash # Ruby stuff yum erase -y ruby rubygems # Ruby 1.9.3 dependencies (MUST NOT FORGET, otherwise many gems will be error at their installation) yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel yum install -y ruby19-devel ln -s /usr/bin/ruby1.9 /usr/bin/ruby ln -s /usr/bin/gem1.9 /usr/bin/gem yum install -y aws-amitools-ec2 # Install Passenger gem gem install passenger # Install Nginx dependencies yum install -y curl-devel # Reload bash for passenger-related binary source ~/.bashrc # Install Nginx with Passenger # with a sequence of key # 1. Enter (Skip Intro) # 2. 1 and Enter (Install Nginx) # 3. Enter (Install PCRE) # 4. Enter (Use default dir) # 5. Enter (Skip the end) echo -e "\n1\n\n\n\n" | /usr/local/bin/passenger-install-nginx-module # Install Git yum install -y git # Now don't forget to configure Nginx. That's it.

Give it a kudos