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 协议》,转载必须注明作者和本文链接
日拱一卒
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

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