环境准备
所需软件 | 下载地址 |
---|---|
VirtualBox-5.2.8-121009-Win | https://download.virtualbox.org/virtualbox/5.2.12/VirtualBox-5.2.12-122591-Win.exe |
vagrant_2.1.1_x86_64 | https://releases.hashicorp.com/vagrant/2.1.1/vagrant_2.1.1_x86_64.msi |
vagrant-centos-7.2.box | https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.2/vagrant-centos-7.2.box |
安装Virtualbox+Vagrant
略
配置环境
- 创建共享目录
- 进入目录,添加box
vagrant box add Djstudy1 D:\im
ages\vagrant-centos-7.2.box
- 初始化
vagrant init Djstudy1
初始化后会在目录中建个Vagrantfile,可以在文件中加入如下两行(指明虚机的账号密码)
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
- 启动虚拟机
vagrant up
- 登录虚拟机
vagrant ssh
- 查看当前虚拟机状态
vagrant status
- 关闭虚拟机
vagrant halt
- 暂停虚拟机
vagrant suspend
- 重启虚拟机
vagrant reload
- 销毁虚拟机
vagrant destory
配置PyCharm环境
Tools --> Vagrant --> Init in Project Root --> Djstudy1