Vagrant使用教程

vmware下载地址:https://www.vmware.com/products/workstation-pro/workstation-pro-evaluation.html 

VirtualBox下载地址:https://www.virtualbox.org/wiki/Downloads

Vagrant下载地址:https://developer.hashicorp.com/vagrant/install#Windows

Vagrant镜像下载地址:https://app.vagrantup.com/boxes/search

新建一个文件夹

D:\vagrant\centos7

生成centos/7 Vagrantfile

vagrant init centos/7

创建并启动虚拟机

vagrant up

连接虚拟机

vagrant ssh

重启虚拟机

vagrant reload

Vagrantfile

virtual box

Vagrant.configure("2") do |config|

  # 使用CentOS 7的官方Vagrant box
  config.vm.box = "centos/7"

  # 设置固定ip
  config.vm.network "private_network", type: "static", ip: "192.168.33.10"

  # 设置虚拟机内部的主机名
  config.vm.hostname = "centos7-vm"

  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    # 设置VirtualBox界面上显示的虚拟机名称
    vb.name = "centos7-vm"
    vb.memory = "1024"
    vb.cpus = 2
  end
  
end

VMware

Vagrant VMware Utility下载地址:https://developer.hashicorp.com/vagrant/install/vmware

使用管理员身份打开命令提示符,安装插件

vagrant plugin install vagrant-vmware-desktop
Vagrant.configure("2") do |config|
 
  # 使用CentOS 7的官方Vagrant box
  config.vm.box = "centos/7"
 
  # 设置固定ip
  config.vm.network "private_network", type: "static", ip: "192.168.33.10"
 
  # 设置虚拟机内部的主机名
  config.vm.hostname = "centos7-vm"
 
  # 使用VMware提供者
  config.vm.provider "vmware_desktop" do |vmware|
    
    # 配置内存和CPU
    vmware.memory = "1024"
    vmware.cpus = 2
  end
 
end

账号密码

账号:

        普通用户:vagrant

        管理员:root

密码:vagrant

Xshell/FinalShell连接虚拟机

su root

vim /etc/ssh/sshd_config

PasswordAuthentication yes

PermitRootLogin yes

systemctl restart sshd

  • 9
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

晨晨OvO

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值