Getting up Rails up and running on Amazon’s EC2

This is just for documentations sake, and only if you’re running Ubuntu 12.x. If you are running Ubuntu 12.x on an EC2 instance, then don’t use Ruby on Rails, it’s a pain to deploy. Amazon’s AMI is a homebrewed version of Linux that comes with Ruby ready, which is a better solution. However if you want to install rvm on your Ubuntu machine follow the documentation below:

  1. sudo apt-get update
  2. sudo apt-get install build-essential git-core curl libmysqlclient15-dev nodejs libcurl4-openssl-dev
  3. sudo bash -s stable < <(curl -s
  4. umask g+w
  5. source /etc/profile.d/
  6. rvm requirements
  7. sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
  8. sudo chown -R [user]:[user] /usr/local/rvm
  9. rvm install 1.9.3
  10. rvm –default use 1.9.3

If you are using rails:

  • gem install rails

If you are using passenger (with nginx):

  1. gem install passenger
  2. rvmsudo passenger-install-nginx-module
  3. copy over the /etc/init.d script from the wiki and fit it to your install

Now you think you’re set right?! Well if you’re developing apps on that instance, yes, you’re ok. I ran into an error with capistrano where it refused to use rvm’s ruby to precompile the assets for production, I found that I had to install ruby1.9.1 to get it to work.