1. Vagrantfile Introduction
Vagrantfile is a simple text file that allows you to define various configurations of a virtual machine, such as network, memory, hostname, and so on, each project needs to have a vagrantfile, which can be found in the directory where Vagrant Init is executed, or it can be written manually
2. Configuration
Vagrant.configure (2) do |config| //vagrant starter configuration block config.vm.box = "CentOS" //define box name config.vm.hostname = "hostname" //define virtual machine name config.vm.box_url = "C:/me/vagrant-centos-6.7.box" //Specify base Mirror location config.vm.synced_folder "/ Path/to/share ", " Path/to/mount " //the first parameter is a shared directory on the host, and the second parameter is the mount directory of the vagrant virtual machine config.vm.network "Forwarded_port", guest: 80, host: 80 // Map the 80 port of the vagrant virtual machine to the host's 80 port----------------------SSH-related configuration-------------------------------------------------------- config.ssh.username = "vagrant" //set default SSH user (default user is vagrant) config.ssh.password = "vagrant" //set default SSH password (default password is vagrant) config.ssh.port = 22 //setting up SSH ports --------------------- Some configuration based on VirtualBox-------------------------------------------- config.vm.provider "VirtualBox" do |v| v.gui = false virtualbox gui v.name = "MY_VM" is not displayed when //is started //name displayed in VirtualBox v.cpus = 2 //Specify the number of virtual machine cores v.memory = "1024x768" //specifying virtual machine memory endend //vagrant end configuration block
This article is from "Mr. Peach" blog, please be sure to keep this source http://peach3412.blog.51cto.com/12037226/1850719
4, Vagrantfile Common configuration