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 协议》,转载必须注明作者和本文链接
推荐文章: