Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Standard Rails 4.* setup for Ubuntu 14.04 LTS

View ubuntu_steps.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
# As root user
 
sudo su
 
# Update the OS
sudo apt-get update -y
 
# Add this to ~/.bashrc to remove timezone warnings
echo 'export LC_ALL="en_US.UTF-8"' >> ~/.bashrc
source ~/.bashrc
 
# Install Rails Requirements
sudo apt-get install build-essential zlib1g-dev curl git-core python-software-properties libssl-dev openssl libreadline-dev -y
# useful extras: libgeoip-dev
 
# Install latest stable Nginx
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update -y
 
sudo apt-get install nginx -y
service nginx restart
 
# Install Node
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get update -y
sudo apt-get install nodejs -y
 
# Install Firewall
apt-get install ufw -y
ufw enable
# enable ssh, either on default 22 or a port you change it to
ufw allow 22
# enable http etc...
ufw allow 80
 
# Add Deployment User
groupadd admin
adduser deployer --ingroup admin
su deployer
 
# (logout)
 
# brew install ssh-copy-id
# ssh-copy-id deployer@SERVER_IP
# ssh deployer@SERVER_IP
 
# Say hello to git (expect response: Permission denied (publickey).)
ssh git@github.com
 
# Install rbenv
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
echo 'eval "$(rbenv init -)"' >> ~/.profile
exec $SHELL -l
 
# Install Ruby 2.2.2
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv rehash
rbenv install 2.2.2
# ^ go and get a coffee, rbenv install takes a while
rbenv global 2.2.2
 
# Check installation went OK
ruby -v
 
# Install Bundler
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
gem install bundler
rbenv rehash
 
# ...
# Install postgres, redis, varnish etc
 
 
 
# Install Postgres 9.4
sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update -y --fix-missing
sudo apt-get install -y libpq-dev postgresql-9.4
 
sudo -u postgres psql
\password # enter a root user password
create user <appname> with password 'secret';
create database <appname>_production owner <appname>;
\q
 
# generate ssh keys for github if private repo
ssh-keygen -t rsa -b 4096 -C "YOUR_EMAIL"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub # paste in https://github.com/settings/ssh
ssh -T git@github.com
 
# capistrano 3
cap production deploy:setup_config
cap production deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.