

Syncing project filesĪ good practice to follow when you’re using a Vagrant development environment, or as a matter of fact any virtualized development environment, is to share your project files between the host and the guest operating systems, so that your project files are not copied into the virtual machine, because if you delete your VM, the files will be lost with it.

If port collisions occur, Vagrant will output the corrections during the vagrant up boot up process. There are cases when you have multiple vagrant boxes running with the same port open on the host machine, in these cases Vagrant will automatically resolve the conflicting ports. The auto_correct option set to true tells Vagrant to handle port collisions automatically. What the above line defines is that if you have a web server inside the virtual machine listening on port 80, then it can be accessed from the host machine on port 8931, for example by typing localhost:8931 in your browser. Insert the following line into your configuration file: config.vm.network :forwarded_port, guest: 80, host: 8931, auto_correct: true

We’re going to set up port forwarding for now. Vagrant has multiple ways of allowing us to communicate with the virtual machine from the outside world, such as public or private network and port forwarding. Let’s write this option in the configuration file, inside the block: config.vm.box = "primalskill/ubuntu-trusty64" Network configurationsĪfter all this is set up, we need to specify the network configurations. That base box is hosted on Vagrant Cloud, so we only need to specify the name and Vagrant will automatically get it from there. Next, we need to specify the base Vagrant box we created in the introductory post. Let’s write this block in our Vagrantfile. The current one is version 2 which works with Vagrant 1.1 and up. So in every Vagrantfile we need to specify which version to use. Vagrant uses API versions for its configuration file, this is how it can stay backwards compatible. Before we can start provisioning the base box, we need to set a few required options in our configuration file.
