Introduction:

DigitalOcean.com is a website that provide rental server for varies usage, one of those usage they mainly focus on is rails server hosting, with this focus, they provide a dedicated VM setup that came with ruby runtime and rails installed. In DigitalOcean’s term, a server is called a Droplet. In this tutorial, I will take you through the step I took to setup rails server. Some of the steps might be dated, so keep that in mind when you read this tutorial.

Step1-Create DigitalOcean Account:

  1. Go to DigitalOcean.com
  2. Click on “Signup”
  3. Enter required info
  4. Complete signup
  5. Login

Step2-Create Droplet:

  1. While in admin page, click “Create Droplets”Create Droplet Button Location.png
  2. Choose an OS that you wanna VM to run, we tested Ubuntu(Version 16.04.2) and it works as a rails server host.
    Choose OS.png
  3. In choose a size section, choose the configuration you want for VM.
    Choose Configuration.png
  4. Choose a datacenter region, this is where VM physically locate at.
    Choose Server Location.png
  5. Click “One-click apps” tab, select Ruby on Rails, this will install Ruby on Rails on VM.
  6. Leave other field as default, click on “Create”, give DigitalOcean about 60 seconds to setup VM, during this period, DigitalOcean will send you a email contains username and password, you will need to change password in later step.

Step3-Change default root password:

  1. In admin page, click on the droplet you just created, enter the Droplet admin panel as shown below:


  2. Click on “Console”.
    Open Console.png
  3. To login, enter the username and password that sent you through email.
  4. After successfully logged in, system will ask you for a new password, type and retype new password.

Option Step-SSH into Droplet:

Although console that you can open through web browser provide you most of functionality that you will need, but you may prefer access Droplet through shell installed on your computer.

  1. Open a terminal window on your computer.
  2. Type ssh root@DROPLET_IP_ADDRESS, you can get Droplet’s public IP address from Droplet admin page.
    Get Public IP.png
  3. After login, you will have access to Droplet from your favorite shell.
    1. You may get some confirmation message, type yes and return.
    2. If this is not the first time your computer ssh into Droplet and you rebuild VM, you will get a error message, delete corresponding line in text mentioned in error message, try ssh again.

Step4-Git clone Career Raider from bitbucket:

  1. Open console from droplet admin page
    Console.png
  2. Run “ssh-keygen” to generate SSH key.
  3. Rub “cat /root/.ssh/id_rsa” and copy the output.
  4. Go to your Bitbucket account setting page, add copied key to your account.
  5. Go back to console, run git clone to clone repository.

Option Step-Adjust Ruby Version

  1. Run “rvm install DESIRED_RUBY_VERSION” to install ruby with specific version.
  2. Run “ram use DESIRED_RUBY_VERSION” to use ruby with specific version.

Step 5-Start Rails Server and Tweak Fire Wall

  1. “cd” into rails project, run “bundle install” and any necessary commands to get database setup.
  2. Run “rails s” to start server on loopback IP.
  3. Run “sudo ufw allow 3000” to let fire wall allow traffic through port 3000.

Now, you can go to your browser and access rails website through Droplet’s public IP.

Advertisements