How to use Vagrant to build a Centos virtual machine

藏色散人
Release: 2020-08-24 15:13:47
forward
1936 people have browsed it

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!

How to use Vagrant to build a Centos virtual machine

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
Copy after login

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/
Copy after login

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
Copy after login

5 , Modify the virtual machine configuration

$ sudo vi Vagrantfile
Copy after login

How to use Vagrant to build a Centos virtual machine

6. Start the virtual machine. You can log in as root or vagrant user. The default password is vagrant

$ sudo vagrant up
Copy after login

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
Copy after login

8. Stop the virtual machine

$ sudo vagrant halt
Copy after login

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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!