了解
vagrant简介 - 我没有领悟 - 博客园 (cnblogs.com)https://www.cnblogs.com/marshhu/p/11880784.html
- 下载适配版本 首先需要安装虚拟机vitualbox(Oracle VM VirtualBox https://www.virtualbox.org/) 然后 vagrant官网下载(Install | Vagrant | HashiCorp Developerhttps://www.vagrantup.com/downloads.html)
- 镜像资源推荐国内 清华大学开源软件镜像站 | Tsinghua Open Source Mirrorhttps://mirrors.tuna.tsinghua.edu.cn/
- 选择自己所需要的镜像资源 小编这边使用ubuntu 在AOSP | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirrorhttps://mirrors.tuna.tsinghua.edu.cn/help/AOSP/ 选择ubuntu寻找自己做需要的版本
- 然后根据以上选择自己的版本 下载地址 Index of /ubuntu-cloud-images/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirrorhttps://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/
- 小编这边使用.box结尾的文件 大家自行所需选择
- 以下是虚拟机部署ubuntu
- 加载镜像有两种方式,大家可自行选择
# 以下是ubuntu20.24展示 # name = ubuntu20.24 # 第一种 vagrant init {name} https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/jammy/20240110/jammy-server-cloudimg-amd64-vagrant.box # 第二种 先把box包下载至本地后加载,path = E:\下载\ubuntu\文件名 Vagrant box add {name} {path} Vagrant init {name} # 运行 vagrant up
-
成功后配置 配置文件Vagrantfile
# 网络配置 config.vm.network "public_network" # 文件夹同步 ### centos config.vm.synced_folder "E:\\project", "/home/vagrant/wwwroot",create: true,owner: "vagrant", group: "vagrant", mount_options: ["dmode=777", "fmode=777"] ### ubunta18 config.vm.synced_folder "E:\\project", "/home/vagrant/wwwroot",create: true, owner:"www-data", group: "www-data"
-
以下是出现的报错(不全面)
vagrant up 出现default: Warning: Authentication failure. Retrying... vi /etc/ssh/sshd_config PermitRootLogin yes PasswordAuthentication yes systemctl restart sshd vagrant reload
出现umount: /mnt: not mounted. 以上的问题是因为虚拟机没有装VBoxGuestAdditions,(增强组件) ubuntu系统处理方案 sudo apt-get update && sudo apt-get install virtualbox-guest-utils centos系统处理方案 sudo yum update && sudo yum install kernel-devel
- vagrant和vitrulBox创建虚拟机后使用xshell连接vagrant和vitrulBox创建虚拟机后使用xshell连接_xshell连接vagrant-CSDN博客https://blog.csdn.net/qq_41793064/article/details/107518577
- 或使用密钥登陆 查看ssh配置
vagrant ssh-config