Developing in Virtual Machine

Why use a Vertial Machine?

It is easiest to develop the websites locally, but there are advantages to develping inside a virtual machine. If you are planning to run a simple blog building a virtual machine does not make sense, but if you are planning to do some serious programming, it may be worth the investment to set up a virtual machine.

A virtual machine is like having a computer running inside a computer, in fact you can have as many guest computers as can fit into the computer memory.

Diagram

Working in Virtial Machine Pros and Cons

ProsCons

- If something crashes the computer, like an instlled program, the guest can be rebuilt withing just few hours.

- The guest can be backack up periodically and restored if needed.

- The guest can be exactly the same setup as the server, therfore what works while developing, will work in production.

- Time investment to install

- Requires a more powerful computer with more memory to run computer inside computer

- The networking between host and guest is sometimes difficult to understand.

The easiest to use the VirtualBox virualizatin product.

To setup, download by clicking on Windows Host to run the VirtualMachine in Windows, and OS X hosts to run on Mac OX.

After downloading the packages, install them.

My distribution of choice is the Ubuntu Server

Connecting to the Headless server

VirtualBox Settings Image
  1. Select the virtual machine to edit

  2. Click on Settings

Virtul Box Network
  1. Selct Network tab

  2. Make sure the Enable Network Adapter is checked

  3. Select NAT

  4. Click on Port Forwarding

VirtualBox port
  1. Clic on the Plus Sign to add a rule

  2. Give the rule a name, its a note for yourself.

  3. Add the Host port, 2222 for SSH is a normal port.

  4. Add port 22 for host.

Restart the virtual machine.

Serving Hugo from VirtualBox

$  hugo server --bind=10.0.2.15