Windows10 安装 virtualbox vagrant ubuntu 14.04 虚拟机

ゞ 浴缸里的玫瑰 2022-05-16 08:20 526阅读 0赞

一、准备:
本机windows10.
下载VirtualBox(我的版本:5.1.26-117224-Win),vagrant(我的版本:1.9.3),putty(连接虚拟机用),
box文件(地址:http://www.vagrantbox.es/,我下载的是Ubuntu 14.04 (based on amd64 server iso file),详细链接是:https://github.com/kraksoft/vagrant-box-ubuntu/releases/download/14.04/ubuntu-14.04-amd64.box)
二、安装:
点击VirtualBox-5.1.26-117224-Win.exe,一直下一步就可以。
点击vagrant_1.9.3.msi,一直下一步就可以。
三、创建vagrant项目目录, 比如:d:\vagrant(最好把上面下载的box文件放到此目录下)。
然后切换到d:\vagrant\目录下,执行下列命令。
vagrant box add ubuntu1404_1 ./ubuntu-14.04-amd64.box # 添加虚拟机 add {name} {box file}
vagrant box list # 查看虚拟机列表
vagrant init # 初始化

  1. 在当前目录下找到Vagrantfile文件,并打开修改,
  2. 把这行config.vm.box = "base" base换成你在add的时候的名字.
  3. 把这行config.vm.synced\_folder "../data", "/vagrant\_data",修改成你要共享的目录。比如 config.vm.synced\_folder "D:/tmp/vagrant\_share", "/var/www"
  4. 修改完了,并保存。
  5. vagrant up --provider virtualbox \# 启动虚拟机
  6. vagrant ssh \# 连接虚拟机
  7. 接下来就可以用putty连接虚拟机了,用户名和密码都是vagranthost:127.0.0.1port:2222
  8. vagrant reload \# 重启虚拟机

四、可能出现的问题
a:
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem “vboxsf” is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

  1. mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
  2. The error output from the command was:
  3. mount: unknown filesystem type 'vboxsf'
  4. 解决办法:vagrant plugin install vagrant-vbguest \# 安装增加插件
  5. 然后再执行 vagrant provision
  6. a:
  7. \`ssh\` executable not found in any directories in the %PATH% variable. Is an
  8. SSH client installed? Try installing Cygwin, MinGW or Git, all of which
  9. contain an SSH client. Or use your favorite SSH client with the following
  10. authentication information shown below:
  11. Host: 127.0.0.1
  12. Port: 2222
  13. Username: vagrant
  14. 意思是:没有找到SSH客户端,需要安装CygwinMinGWGit等。可以通过putty来访问。

发表评论

表情:
评论列表 (有 0 条评论,526人围观)

还没有评论,来说两句吧...

相关阅读