How to create your own Homestead

After reading 开发环境搭建 - MacOS, I found using homestead is very easy and convenient. But I if mess something up, do I have to work from scratch? How to create my own homestead?

After reading some other articles, I realized the homestead is a custom vagrant, so I read part of the vagrant docs.

When I felt that all were ready, I tried to create my own homestead.

Pack the current environment

cd ~/Homestead
mkdir someDirectory         # change to your own directory name
vagrant package --output someDirectory/virtualbox.box
cd someDirectory
vi metadata.json 

Type the following code below:

{
    "name": "my_lc/homestead",
    "versions":
    [
        {
            "version": "6.1.0",
            "providers": [
                {
                    "name": "virtualbox",
                    "url": "virtualbox.box"
                }
            ]
        }
    ]
}

Then add the box to vagrant

> vagrant box add metadata.json
==> box: Loading metadata for box 'metadata.json'
    box: URL: file:///Path/someDirectory/metadata.json
==> box: Adding box 'my_lc/homestead' (v6.1.0) for provider: virtualbox
    box: Downloading: virtualbox.box
==> box: Successfully added box 'my_lc/homestead' (v6.1.0) for 'virtualbox'!

you can see the added box list

> vagrant box list
laravel/homestead (virtualbox, 6.1.0)
lc/homestead      (virtualbox, 6.1.0)
my_lc/homestead   (virtualbox, 6.1.0)


Edit the homestead.yaml, add some parameters

cd ~/Homestead
vi Homestead.yaml

add some parameters as below:

name: my_homestead-7       # name is the name of VM
box: my_lc/homestead         # box is the logical name of vagrant box, u can find it in metadata.json or specify it when u add box with --name flag.


Cleanup

Delete the verbose box file and clean VM files

vagrant box remove lc/homestead

Then go to the virtualbox UI, choose the VM u want to delete, select remove on the context menu, press the "Delete all files" button on the popup.


Enjoy the work!

本作品采用《CC 协议》,转载必须注明作者和本文链接
日拱一卒
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
未填写
文章
92
粉丝
87
喜欢
152
收藏
121
排名:72
访问:11.3 万
私信
所有博文
社区赞助商