Vagrant structures used in win7 / win10 system

What vagrant that?

   a vagrant is a virtual machine tool
   by commands and configuration files to manage virtual machines, will soon be able to deploy a complete development environment, and can be packaged spread, unified development environment, but also solve the problems reconfigurable environment.

The benefits Vargant

1. unified development environment.
   A configuration package, unified distributed to team members, team unified development environment, addressing issues such as "coding problems", "Missing module", "different profiles" problems caused by;

2. Avoid duplicate setup the development environment.
   New employees, do not waste time to setup the development environment, developers quickly added, reducing the cost of wasted time;

3. Multiple isolated development environment.
   Can not run in the box in a different language, or compile and install a different version of the same language, set up multiple isolated development environment is also very clear when unloading quick and easy.

Using the procedure win7 / win10 system
1, install VirtualBox, vagrant two software

  Directly to the official website to download and install the official website as follows:  
https://www.virtualbox.org
https://www.vagrantup.com
  official website of the range is slow, and the two different versions of the software may cause compatibility problems, that is, there your vagrant may cause some strange problems with it, so it is best to develop two versions of the installation.
  win10 version:
VirtualBox-5.2.12-122591-win.exe
vagrant_2.2.7_x86_64.msi

 

2, download an image file box

After installing a box need to download the image file, which is a mirror image of linux (in fact, you can also specify the name of the official mirror directly when vagrant add installation will automatically download and install, but given the country's official download speed is too slow, so strong in view of the first with a tool like Thunder accelerate download and then installed locally)
  download the official website at the following address:
https://app.vagrantup.com/boxes/search
  If you are installing centos, then click on the link below directly:
HTTPS: // App. vagrantup.com/centos/boxes/7

3, the image is loaded into the container vagrant

  Execute the following command:
    vagrant box add -name [虚拟机名称] [box放置的位置]
  CentOS / 7 virtual machine name of the last of the box to place written directly after you download back to the root directory can be, if not specified, the default will have downloaded from the official website
  such as: vagrant box add -name 'centos / 7 '[box placed position]

  Here is my own position placed habits:
 
upload successful
upload successful

$ vagrant box add xuni CentOS20200119.box
4, initializing the virtual machine
$ vagrant init xuni

vagrant init command is the initial word command
xuni is the name of the box (that is, the third step [Virtual Machine Name] that position)

5, start the virtual machine

After the initial, then you can begin to start the virtual machine, run the following command:

$ vagrant up
D:\>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'xuni'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: _default_1583637544209_19565
Vagrant is currently configured to create VirtualBox synced folders with
the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:

  https://www.virtualbox.org/manual/ch04.html#sharedfolders

This option can be disabled globally with an environment variable:

  VAGRANT_DISABLE_VBOXSYMLINKCREATE=1

or on a per folder basis within the Vagrantfile:

  config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false
==> default: Vagrant has detected a configuration issue which exposes a
==> default: vulnerability with the installed version of VirtualBox. The
==> default: current guest is configured to use an E1000 NIC type for a
==> default: network adapter which is vulnerable in this version of VirtualBox.
==> default: Ensure the guest is trusted to use this configuration or update
==> default: the NIC type using one of the methods below:
==> default:
==> default:   https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type
==> default:   https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: You are trying to forward to privileged ports (ports <= 1024). Most
==> default: operating systems restrict this to only privileged process (typically
==> default: processes running as an administrative user). This is a warning in case
==> default: the port forwarding doesn't work. If any problems occur, please try a
==> default: port higher than 1024.
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: password
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => D:/

Description see this content you start the virtual machine has been installed properly finished!

6, connected virtual machines 

If the connection is to modify the base image, then use the official beginning Rom, you need to modify the configuration by entering the following command to configure ssh
1, modify sshd_config configuration
into the virtual machine, login account passwords are: vagrant
into the folder / etc / ssh, modify the configuration file sshd_config
cd / etc / SSH
vi sshd_config  

upload successful

Restart sshd.service Service

systemctl restart sshd.service

Local use Xshell connect virtual machines, run the following command:

ssh 127.0.0.1 2200

In the pop-up window, enter your user name and password to enter the virtual machine. ssh command represents the connection, 127.0.0.1 2200 can be found vagrant up when the output of the command.

7, using the tools to connect the virtual machine xshell

It can also be directly connected directly with the ssh command's official website, but the connection with the ssh command or cmd window in the future development of less convenient in win, the best tool is connected xshell.

upload successful
The default account and password are direct: vagrant can, (individual into account root login, password or vagrant)

This concludes, then adjust the details of the mirror and the like After completion of the package directly into their own image, for future use in other computers or virtual machines present the problem of the computer, it can be mounted directly to a key (corresponding to reduction)
DETAILED own box packing method I also have a blog tutorial http://tiance.club/post/299409888.html

Author: xingguang
link: Original link: https://www.tiance.club/post/2370098709.html

Guess you like

Origin www.cnblogs.com/yizhidaozuihou/p/12446068.html