I have been working on setting up a Ruby on Rails project and using Amazon Web Services (AWS) to host it. AWS EC2 instance out of the box of course is not setup to run rails. After much trial and error I have narrowed down the setup process as listed below.
1 – Setup AWS EC2 Instance (your milage may vary – Assume you have setup EC2 instance before)
I used the following:
AMI – Amazon Linux AMI 2016.03.1 (HVM), SSD Volume Type – ami-f5f41398
Instance Type: General purpose t2.medium
2 – Setup Rails Environment
Connect to EC2 Instance (ssh via terminal)
ssh -i "****.pem" ec2-user@ec2-XX-XX-XXX-XX.compute-1.amazonaws.com
Always a good practice on new installs $ sudo yum update Install rvm for Ruby Version Management $ gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 $ curl -L https://get.rvm.io | bash -s stable $ source ~/.profile Install zlib-devel $ sudo yum install zlib-devel (don't exactly remember why this is needed - might be application specific) Install openssl $ rvm pkg install openssl $ rvm reinstall 2.0.0 --with-openssl-dir=/usr/local/rvm/usr (ruby version up for debate) my ruby project uses bundler - install it $ gem install bundler my application also require javascript $ sudo yum install nodejs npm --enablerepo=epel install git $ sudo yum install git $ git clone https://github.com/xxxxx/yourrepo.git $ cd yourrepo run bundle install (again, my app uses it - your app may have other install steps $ bundle install $ rails s You should see something like: varies depending on application server=> Booting WEBrick => Rails 3.2.12 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server Connecting to database specified by database.yml [2016-05-24 13:56:28] INFO WEBrick 1.3.1 [2016-05-24 13:56:28] INFO ruby 2.0.0 (2015-12-16) [x86_64-linux] [2016-05-24 13:56:28] INFO WEBrick::HTTPServer#start: pid=27261 port=3000