# vagrant-ubuntu-for-win **Repository Path**: zxf.0810/vagrant-ubuntu-for-win ## Basic Information - **Project Name**: vagrant-ubuntu-for-win - **Description**: No description available - **Primary Language**: Shell - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 8 - **Forks**: 0 - **Created**: 2020-07-09 - **Last Updated**: 2025-08-19 ## Categories & Tags **Categories**: lamp **Tags**: None ## README # vagrant-ubuntu-for-win ### 背景 - 作为PHP开发者,使用laravel/homestead太过笨重 - 开发过程中,经常碰到开发,测试,线上环境不一致导致的各种问题 --- ### 介绍 在window上,搭建同测试和线上运行环境一致的Ubuntu系统,作为我们的统一开发环境。 包括: - Window10 - VirtualBox - Vagrant - Ubuntu - Docker + docker-compose - Git + TortoiseGit ![](https://img.slimframework.net/imgs/2020/07/cc764230305b5eae.png) --- ### 安装使用 1.安装vagrant和VirtualBox 1)vagrant_1.9.7_x86_64.msi 2)VirtualBox-5.1.26-117224-Win.exe 3)Ubuntu14.4.box 国内下载资源: Vagrant: https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.msi(建议用迅雷) VirtualBox: https://mirrors.tuna.tsinghua.edu.cn/help/virtualbox/ box: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/bionic/current/bionic-server-cloudimg-amd64-vagrant.box 2.载入box镜像 vagrant box add ubuntu14.4 ubuntu14.4.box 3.下载vagrant配置(根据自己需要修改vagrant) git clone https://gitee.com/zxf.0810/vagrant-ubuntu-for-win.git 4.运行启动环境 cd vagrant-ubuntu-for-win vagrant up 5.连接Ubuntu(推荐使用xshell) ip:127.0.0.1 port: 2200 (vagrant up启动时会打印 default: 22 (guest) => 2200 (host) ) user: vagrant pass: vagrant vagrant-ubuntu-for-win 对应服务器中 /vagrant 目录 ![](https://img.slimframework.net/imgs/2020/07/0bd2b7511a70c1d8.png) 6.运行脚本 ./job.bat start 运行vagrant及docker-compose服务 ./job.bat stop 关闭服务 --- ### vagrant使用说明 1.vagrant 常用命令 $ vagrant box add NAME URL #添加一个box $ vagrant box list #查看本地已添加的box $ vagrant box remove NAME virtualbox #删除本地已添加的box,如若是版本1.0.x,执行 $ vagrant box remove NAME $ vagrant init NAME #初始化,实质应是创建Vagrantfile文件 $ vagrant up #启动虚拟机 $ vagrant halt #关闭虚拟机 $ vagrant destroy #销毁虚拟机 $ vagrant reload #重启虚拟机 $ vagrant package #当前正在运行的VirtualBox虚拟环境打包成一个可重复使用的box $ vagrant ssh #进入虚拟环境 2.打包当前虚机为box vagrant package --output test.box --vagrantfile ./Vagrantfile --include ./file.zip 3.使用已经存在的box mkdir /opt/dev cd /opt/dev vagrant box add dev-test ~/test.box (或者http://files.vagrantup.com/precise64.box,该在线服务在海外非常慢,建议用迅雷下载) vagrant init dev-test vagrant up --- ### ToDo List - Mac下搭建运行环境 - 提供国内下载资源 - 面向公司的Window安装镜像(开箱即用) --- ### 相关推荐 - [lnmp-docker-compose](https://gitee.com/zxf.0810/lnmp-docker-new) (基于docker-compose的lnmp运行环境) --- ### 更新记录 **2020/07/09** - 初始化项目 --- ### 问题咨询 微信:marlin-online QQ:3392175105