Skip to content

Instantly share code, notes, and snippets.

@jasonpilz
Last active July 4, 2019 09:49
Show Gist options
  • Save jasonpilz/2bdc6eb53378703004da to your computer and use it in GitHub Desktop.
Save jasonpilz/2bdc6eb53378703004da to your computer and use it in GitHub Desktop.
Getting a VPS set up

Mission

  • Setup for a new DigitalOcean/AWS EC2/Linode server.

Software we need on the VPS

sudo apt-get update
sudo apt-get install htop 
sudo apt-get install tmux 
sudo apt-get install vim
sudo apt-get install git

Configure Git

cd
git config --global user.name "Your Name"
git config --global user.email your_email@address.com

Install basic packages

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

Install Rbenv (Info)

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec $SHELL

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
exec $SHELL

. .bashrc
. .bash_profile

git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash

Install Ruby

rbenv install 2.2.3
rbenv global 2.2.3
ruby -v

Disable docs for future gem installs

echo "gem: --no-ri --no-rdoc" > ~/.gemrc

Node for Ubuntu

dpkg --get-selections | grep node
sudo apt-get purge nodejs npm
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
node -v
npm -v
Now to force update to the freshest version of everything:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Install Rails for Ubuntu

gem install rails -v 4.2.5

Rehash

rbenv rehash

Verify installations

ruby -v
rails -v
node -v
npm -v

Install Pry and AG

gem install pry
gem install ag

Install PostgreSQL

cd
sudo apt-get install postgresql postgresql-contrib libpq-dev

sudo -u postgres createuser -s user_name
sudo -u postgres psql
\password user_name
You will be prompted to enter a password and confirm, so go ahead and do that...then:
\q

Redis (Optional)

sudo apt-get update
sudo apt-get install tcl8.5
wget http://download.redis.io/releases/redis-stable.tar.gz
tar xzf redis-stable.tar.gz
cd redis-stable
make
make test
sudo make install
cd utils
sudo ./install_server.sh
You will be prompted to enter some settings for redis configuration. Just hit enter each time to accept the defaults.
At this point, redis server should be running, can test with:
redis-cli ping 
If running, will output 'PONG'.
If you need to manually start / stop redis:
service redis_6379 start
service redis_6379 stop

Misc commands

Install Updates
apt-get update && aptitude dist-upgrade -y && apt-get autoremove -y
Reboot
sudo reboot
Start Rails server as daemon
RAILS_ENV=production rails s -d -b [servers_ip_address] -p 80
Get SSH Key
cat ~/.ssh/id_rsa.pub | pbcopy
Add SSH key to VPS
cat ~/.ssh/id_rsa.pub | ssh user_name@your_server_ip 'cat >> .ssh/authorized_keys'

Credits:

Content hijacked from:

  • the excellent gist by the real french king, Regis Boudinot (Source)
  • the legendary Turing instructor, Steve Kinney (Source)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment