First install VirtualBox ~~
Then install vagrant.
Set the environment:
If the vagrant command is unavailable, add this directory to the environment variable PATH: D: \ ProgramS \ Vagrant \ bin; (D: \ ProgramS \ Vagrant is the Vagrant installation directory)
PATH: add D: \ ProgramS \ VirtualBox. You can install the PATH of VirtualBox to ensure that the VBoxManage command is available in cmd.
Add the environment variable VAGRANT_HOME: just write it in the directory path of another disk.
Create a directory for a disk
Start-> run cmd to go to the directory created in the previous step.
Vagrant box add centos ~ /Box/precise64.box is used after the red name
Vagrant init centos # initialization
In Notepad, open the Vagrantfile file in the directory and configure the following information:
Vagrant up # Start the environment
Restart vagrant reload
Vagrant halt shutdown
Ps: configuration file
#-*-Mode: ruby -*-
# Vi: set ft = ruby:
# All Vagrant configuration is done below. The "2" in Vagrant. configure
# Configures the configuration version (we support older styles
# Backwards compatibility). Please don't change it unless you know what
# You're doing.
Vagrant. configure (2) do | config |
# The most common configuration options are supported ented and commented below.
# For a complete reference, please see the online documentation
# Https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search
# Boxes at https://atlas.hashicorp.com/search.
Config. vm. box = "archlinux" # The Red position is the name marked with red above.
# Disable automatic box update checking. If you disable this, then
# Boxes will only be checked for updates when the user runs
# 'Vagrant box outdated'. This is not recommended.
# Config. vm. box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# Within the machine from a port on the host machine. In the example below,
# Accessing "localhost: 8080" will access port 80 on the guest machine.
# Config. vm. network "forwarded_port", guest: 80, host: 8080 ing linux ports to external use
# Create a private network, which allows host-only access to the machine
# Using a specific IP.
# Config. vm. network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# Your network.
# Config. vm. network "public_network"
Config. vm. network "public_network", ip: "192.168.1.71", set bridging ip addresses to public IP addresses. Port ING is recommended.
# Share an additional folder to the guest VM. The first argument is
# The path on the host to the actual folder. The second argument is
# The path on the guest to mount the folder. And the optional third
# Argument is a set of non-required options.
# Config. vm. synced_folder "../data", "/vagrant_data"
Config. vm. synced_folder "D:/webroot", "/var/webroot" configure some shared directories
# The settings below are self-built Baidu
# Provider-specific configuration so you can fine-tune various
# Backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# Config. vm. provider "virtualbox" do | vb |
# Display the VirtualBox GUI when booting the machine
# Vb. gui = true
#
# Customize the amount of memory on the VM:
# Vb. memory = "1024"
# End
#
# View the documentation for the provider you are using for more
# Information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# Such as FTP and Heroku are also available. See the documentation
# Https://docs.vagrantup.com/v2/push/atlas.html for more information.
# Config. push. define "atlas" do | push |
# Push. app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# End
# Enable provisioning with a shell script. Additional provisioners such
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see
# Documentation for more information about their specific syntax and use.
# Config. vm. provision "shell", inline: <-SHELL
# Sudo apt-get update
# Sudo apt-get install-y apache2
# SHELL
End