Automate Ruby on Rails setup on EC2

1 Apr 2012

Works only on Amazon EC2 with Red Hat Linux

It starts getting annoying when I have to deploy like 3 Ruby-on-Rails apps.

I'll build a script to ease the process.

Here is the rough outline of all the required installation:

  1. RVM
  2. Ruby 1.9.3
  3. Git
  4. Nginx Passenger

The current draft for Red Hat Linux

Run it with `nohup ./<file>.sh &and ``tail -f nohup.out``` to track the output.

Here is the script:

#!/bin/bash # Install RVM bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) # Reload shell for RVM command source /etc/profile.d/rvm.sh # Install Ruby dependencies 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 libxml2-devel libxslt-devel # Install Ruby 1.9.3 rvm install 1.9.3 # Make 1.9.3 default rvm alias create default 1.9.3 # Install Passenger gem gem install passenger # Install Nginx dependencies yum install -y curl-devel # 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" | passenger-install-nginx-module # Install Git yum install -y git # Now don't forget to configure Nginx. That's it.

Setting up deploy user: (It doesn't work because the change of users.)

#!/bin/bash useradd deploy su deploy echo -e "\n\n\n" | ssh-keygen -t rsa -C "deploy@youremail.com"

Here is an extension that install Mongo and MySQL:

(I haven't done it yet)

Give it a kudos