Skip to content

Instantly share code, notes, and snippets.

@crmaxx
Forked from alanstevens/install-rvm.sh
Last active September 29, 2016 08:25
Show Gist options
  • Save crmaxx/4598302 to your computer and use it in GitHub Desktop.
Save crmaxx/4598302 to your computer and use it in GitHub Desktop.
Amazon AWS EC2 production for Ruby on Rails

Amazon AWS EC2 production for Ruby on Rails

echo 'UseDNS no # if slow connection' >> /etc/ssh/sshd_config
echo 'PrintMotd yes # if you need motd messages' >> /etc/ssh/sshd_config

From /etc/pam.d/login && /etc/pam.d/sshd delete all strings included

session optional pam_motd.so

Update fresh installed cloud

sudo apt-get update && sudo apt-get upgrade

Remove components of paid monitoring

sudo apt-get remove landscape-client landscape-common
sudo apt-get autoremove

Install utilities

sudo apt-get install mc htop curl git-core localepurge

Install devtools

sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev

Install postgresql

sudo add-apt-repository ppa:pitti/postgresql && sudo apt-get update
sudo apt-get install postgresql-9.2 postgresql-client-9.2 postgresql-contrib-9.2 postgresql-server-dev-9.2

Check pg port. It must be 5432

sudo netstat -lp | grep postgresql

Connect to pg via psql

sudo su postgres -c psql

Create a new user

create user username with password 'password';

Grant privelegies for it.

alter user username superuser;

Install alternative malloc. Ruby works on 8-10% faster.

sudo apt-get install libtcmalloc-minimal0
echo 'export LD_PRELOAD=/usr/lib/libtcmalloc_minimal.so.0.1.0' >> ~/.bash_profile
source ~/.bash_profile

Install rvm & ruby & rails

bash -s < <(curl -s https://raw.github.com/gist/4598302/install-rvm.sh)
#!/bin/bash
echo 'Installing RVM'
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
echo '# Ruby tuning' >> ~/.bash_profile
echo 'export RUBY_HEAP_MIN_SLOTS=1000000' >> ~/.bash_profile
echo 'export RUBY_HEAP_SLOTS_INCREMENT=1000000' >> ~/.bash_profile
echo 'export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1' >> ~/.bash_profile
echo 'export RUBY_GC_MALLOC_LIMIT=1000000000' >> ~/.bash_profile
echo 'export RUBY_HEAP_FREE_MIN=500000' >> ~/.bash_profile
source ~/.bash_profile
echo 'Installing ruby 1.9.3-p327 with falcon-gc patch'
rvm get head
rvm install 1.9.3-p327 --patch falcon-gc
rvm use 1.9.3-p327 --default
rvm use 1.9.3-p327@global
echo 'Installing rails'
gem install rails --no-rdoc --no-ri
echo 'Installing bundler'
gem install bundler --no-rdoc --no-ri
echo 'Creating ~/.gemrc'
echo "install: --no-rdoc --no-ri" >> ~/.gemrc
echo "update: --no-rdoc --no-ri" >> ~/.gemrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment