Skip to content

Instantly share code, notes, and snippets.

@lin
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save lin/eefbfa6e1f29f6593c89 to your computer and use it in GitHub Desktop.

Select an option

Save lin/eefbfa6e1f29f6593c89 to your computer and use it in GitHub Desktop.
AWS setup for rails (apache and passenger) and mongodb

Create an ec2 instance

ssh -i ~/.ssh/keypair.pem ec2-user@123.456.789.101

Set up ssh alias.

vi ~/.ssh/config
Host aws
        HostName 123.456.789.101
        User ec2-user
        IdentityFile ~/.ssh/keypair.pem

update yum

sudo yum update
sudo yum groupinstall "Development Tools"

rvm

gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
sudo \curl -sSL https://get.rvm.io | bash -s stable --ruby
source ~/.rvm/scripts/rvm
type rvm | head -n 1

rails and dependencies

sudo gem install rails
gem install railties
sudo yum install sqlite-devel
sudo gem install bundler

nodejs

sudo su -
curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs

have a test

rails new project
cd project
rails generate scaffold User name:string
rake db:migrate

Install passenger

gem install passenger
passenger-install-apache2-module

You might have to install other gems along the way.

Install rails

sudo apt-get update
sudo apt-get install ruby-full build-essential
sudo apt-get install curl
\curl -L https://get.rvm.io | bash -s stable #maybe
sudo apt-get install rubygems
sudo gem install rails
sudo apt-get install libsqlite3-dev
sudo gem install sqlite3-ruby
sudo apt-get install nodejs npm
mkdir ~/www
cd ~/www
rails new app

install nginx

sudo apt-get update
sudo apt-get install nginx
sudo service nginx start

Puma

gem 'puma'
bundle install

create puma.rb at config/puma.rb

environment 'development'
daemonize false
pidfile 'tmp/pids/puma.pid'
state_path 'tmp/pids/puma.state'
threads 0, 16
bind 'unix://tmp/sockets/puma.sock'
activate_control_app 'unix://tmp/sockets/pumactl.sock'

http://ruby-journal.com/how-to-setup-rails-app-with-puma-and-nginx/

http://www.frontcoded.com/rails-on-amazon-ec2-ubuntu.html

http://tommy.chheng.com/2013/01/23/deploying-a-rails-app-on-nginxpuma-with-capistrano/

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