Learn Steps

Learn Vagrant from Scratch : Syncing local folder to the virtual machine

Synced folder are awesome for developers as you will not always want to edit the project, in such case sync the folder edit in your favorite editor and see the results on your vagrant box.

Synced folders are configured within your Vagrantfile using the

config.vm.synced_folder method present in Vagrant setting.

By default vagrant treat root directory as synced folder. To change this to your desired directory follow the below steps.

Vagrant.configure("2") do |config|
  # other config here

  config.vm.synced_folder "src/", "/src/website"
end

The first parameter to is a path to config.vm.synced_folder is a directory on local. If the path is relative, it is relative to the project root. The second parameter must be an absolute path of where to share the folder in virtual machine. This directory and subdirectory will be created if it does not exist.

Now that you have applied the settings. If you are running

vagrant up

settings will automatically be migrated also you have to do

vagrant reload

to apply the settings you have changed. There are other options present for configuring you can learn about them here.