Skip to content

Instantly share code, notes, and snippets.

@selfup
Last active July 7, 2016 17:23
Show Gist options
  • Save selfup/24d5901b0610fdbf7692 to your computer and use it in GitHub Desktop.
Save selfup/24d5901b0610fdbf7692 to your computer and use it in GitHub Desktop.
Use my open source scripts to set up a Ubuntu VPS with Ruby, Rails, NodeJS, and Postgres. Also production ready!

For Ubuntu

SSH into a fresh VPS:

Here we set everything up to be ready for install

cd
sudo apt-get install git -y
git clone https://github.com/selfup/DevOpsOne.git
python ~/DevOpsOne/setup_1.py
. .bashrc
. .bash_profile
python ~/DevOpsOne/setup_2.py
. .bashrc
. .bash_profile
python ~/DevOpsOne/setup_3.py

Now we install the meat and bones (we have to re-run some of the the scripts, they will go by very very quickly this time)

There will be some warnings that things already exists or that things don't exists, but these are normal!

Installing/compiling ruby can take 5 to 10 minutes depending on your setup:

python ~/DevOpsOne/install_ruby.py
python ~/DevOpsOne/setup_1.py
python ~/DevOpsOne/setup_2.py
python ~/DevOpsOne/setup_3.py
rbenv global 2.3.0
rbenv rehash
python ~/DevOpsOne/install_rest.py
rbenv rehash

Ruby, Rails, NodeJS, and Postgres have just been installed. Whoaa!

For security please do the following if you have SSH access

vim /etc/ssh/sshd_config

Hit i to enter INSERT mode

Find the PermitRootLogin and change it to

PermitRootLogin without-password
esc 
:wq
Now hit Enter

Now to ensure that your server cannot be brute forced, do the following:

service ssh restart

Now we hook up a rails app to a postgres database

Don't worry, this is pretty automated!

Clone your favorite app:

cd favorite_app_directory

Run the ruby script that will take a command line argument after the .rb

This will set up a valid database.yml for you (the most painfull process of hooking up a rails app)

ruby ~/DevOpsOne/create_db_yml_server.rb a_password_you_will_remember

Please check your .gitignore and run git status to make sure the script properly added the correct files to your .gitignore

Now we go into the postgres console and input the password we gave to the ruby script as an ARGV[0]

sudo -u postgres psql
\password name_of_favorite_app
\q

Now you can run development/test/production

rake db:setup
RAILS_ENV=production rake db:setup
RAILS_ENV=production rake assets:precompile
RAILS_ENV=production rails s

All done!

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