Setup Vagrant+VirtualBox Ubuntu on Windows 10 to solve problem with symlinks

Table of Content

Have a local Linux environment for Developer is very important now, but its not easy to setup a good system like that especially you are using Windows OS.

Have many tutorials online which may help you set up a Vagrant + VirtualBox to run and Ubuntu instance on VirtualBox, but problem will come when you try to using npm install or somethings on Ubuntu related to symlinks.

To help you avoid that problem, in this tutorial i will introduce step by step to let you install a “good system”.

Step 1 Install Vagrant + VirtualBox on Windows 10

Its easy now, just download both VirtualBox and install them as program on your Windows.

Normally Vagrant will be install at C:\HashiCorp.

Go to this directory on your Windows and create a Vagrantfile :

Above is my vagrant file config which contains something you need to note about :

config.vm.box = "ubuntu/xenial64" : i using Ubuntu 16.

config.vm.box_check_update = false i do not want to check for update each time i start the VM.

I want to forward both port 80 and 3306, so from my windows i can access to WebServer and MySQL Server running on VM through normal port.

config.vm.synced_folder "D:/ubuntu/html", "/var/www/html" : I want to mount folder which i store my code on Windows D:/ubuntu/html to directory /var/www/html on VM Ubuntu.

With this config, i can easy edit the code using Windows IDE Editor and then test them by access through my Windows browser localhost/project, for example.

The most important things on this configuration is the line :

Save those config in C:\HashiCorp\Vagrantfile.

This is part of step to let we can avoid symlinks error on VM, please note that.

Running VirtualBox first time.

Now we need to running VirtualBox first time using Vagrant Commands.

But please note that we must run under Windows Administrator – this is most important thing.

To do that, we open our WIndows CMD as Administrator and go to Vagrant directory :

Now we have vagrant up and running.

Last important command is

Type it in your Windows CMD as Administrator.

Now we can go to test if our VM Ubuntu work correctly with symlink.

Try to install nodejs and run npm install in your project to test.

Thank for watching!

Leave a Reply

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