The following columncentos tutorialwill introduce to you how to use Vagrant to build a Centos virtual machine. I hope it will be helpful to friends in need!
Preparation
1. Vagrant software
2. VituralBox software
3. Centos7 image (.box)
Mirror download link: https://pan.baidu.com/s/1mi5ojqg
1. Create a working directory
$ sudo mkdir /virtual_machine $ sudo mkdir /virtual_machine/centos7
2. Copy Download the Box file to the working directory, and enter the working directory
$ sudo cp /Users/sh/Downloads/centos-7.0-x86_64.box /virtual_machine/centos/ $ cd /virtual_machine/centos/
3. Add the downloaded image to the local warehouse, and specify the alias of the virtual machine to be created in the future as centos7
$ vagrant box add centos7 centos-7.0-x86_64.box
4. Initialize the virtual machine environment. This step generates a Vagrantfile file in the directory. Through this configuration file, you can set the relevant parameters of the virtual machine
$ sudo vagrant init centos7
5 , Modify the virtual machine configuration
$ sudo vi Vagrantfile
6. Start the virtual machine. You can log in as root or vagrant user. The default password is vagrant
$ sudo vagrant up
7. Remote You can connect to the virtual machine or use tools. Here I use root to log in and the password is vagrant
$ ssh -l root -p 22 192.168.33.10
8. Stop the virtual machine
$ sudo vagrant halt
The above is the detailed content of How to use Vagrant to build a Centos virtual machine. For more information, please follow other related articles on the PHP Chinese website!