Initialize a project directory
The first step to configure any Vagrant project is to create a Vagrantfile. The Vagrantfile allows you to:
- Mark the root directory of your project. Many of the configuration options in Vagrant are relative to this root directory.
- Describe the kind of machine and resources you need to run your project, as well as what software to install and how you want to access it.
Prerequisites
Complete the Vagrant Install tutorial or follow the links below to install Vagrant and a virtualization product.
- Install the latest version of Vagrant.
- Install a virtualization product such as; VirtualBox, VMware Fusion, or Hyper-V.
VMware Fusion: There is an additional plugin and configuration required, review the documentation for guidance. Also, note that it is in tech preview for Apple Silicon.
Create a directory
Make a new directory for the project you will work on throughout these tutorials.
Move into your new directory.
Initialize the project
Vagrant has a built-in command for initializing a project, vagrant init
, which can take a box name and URL as arguments. Initialize the directory and specify the hashicorp/bionic64
box.
You now have a Vagrantfile
in your current directory. Open the Vagrantfile, which contains some pre-populated comments
and examples. In following tutorials you will modify this file.
Expand the file below to view the entire contents of the example Vagrantfile.
Next steps
You should commit your Vagrantfile to version control, this will allow every person on the project to benefit from Vagrant without any upfront configuration work.
You have now initialized your first project directory. Continue to the next tutorial to specify a box for your project.