Angkor Brick

Rails: Ubuntu Virtual Development Environment on Window

In this post, I am gonna show how to create a virtual Linux development environment on Window. It is  a bit tricky, so I am summarizing it to use it in the future.

Set up Virtual Box and download Ubuntu OS

This is the first step which to make sure that you should proper configure hardware capacity to meet the system requirement.

Set up development environment on Ubuntu guest OS

This post is all about setting up Rails development environment. What you need are Ruby, Rails, Database server, or Web Server for production, Software version control like Git and other dependencies. The full step to set up is in my previous post.

Create shared folder between host and guest OS

The purpose is to create share folder is to have project directory that can be access (read/write) from both host and guest OS. Some important steps on how to do so is perfectly described in this blog. Thanks author for sharing this that works out for me, and here is my summary:

  • Install Virtual Box Guest Additions vboxsf on guest OS
  • Create a shared folder on host OS by going to Virtual Box setting
  • Run command on guest OS to make project directory and share it across to host OS
  • Run another command to make permanent shared directory when OS boot up
  • To ensure that it works, create files on share directory from host OS. Reboot guest OS and see whether it exists in shared directory of guest OS.

Enable forwarding port for NAT and Set up SSH server on guest Ubuntu OS

  • Go to Virtual Box setting -> Network -> NAT adapter -> Advanced -> Port Forwarding


  • Edit protocol, host port and guest port. Note. port for SSH is 22 but we access from host OS via port 3022


  • Install SSH server on guest OS:
sudo apt install openssh-client 
  • So now you can try access to guest Os via SSH from host OS using putty. Using ip address and port 3022 you configure above. Yay! you can do anything on guest OS using terminal like creating project, run and stop web server…etc.

putty virtualbox2

putty virtualbox1

Enable accessing web server on guest OS (Ubuntu) from host OS (Window)

We still use NAT to access web server on guest OS from host OS by adding more port forwarding rule, set Host Port and Guest Port to 3000 like the figure above in Virtual Box setting. Then you can run web service (Rails) by binding ip address of host OS. To see host ip address in guest OS, run command ifconfig (Linux). Make sure that you already create project Rails, then running web service:

 rails server -b 

Go to web browser in host OS, access application via localhost:3000.


Tags: , ,


Leave a Reply

Your email address will not be published. Required fields are marked *

Perseverance for Best