A bash script that helps you easily create and delete homestead sites on Unix based systems.
Note: You must have Homestead setup and working to be able to use this script.
- Create a folder named
workspace
in you home directory:
$ mkdir ~/workspace
Then move your Homestead
directory (The one you downloaded from Homestead's Github Release Page) into the ~/workspace
folder you just created.
- Create a folder at
~/workspace/www/homestead
:
$ mkdir -R ~/workspace/www/homestead
This is where all your homestead sites will reside in your host machine.
- SSH into your homestead vagrant box and create a
~/projects
folder:
$ cd ~/workspace/Homestead
$ vagrant up
$ vagrant ssh
$ mkdir -R ~/projects
- Edit the
folders
property of yourHomestead.yaml
file to look like the following:
folders:
- map: ~/workspace/www/homestead
to: /home/vagrant/projects
- Download the script and add execute permission:
$ chmod +x /path/to/homestead.sh
- Optional: if you want to use the script globally, you need to copy the file to your
/usr/local/bin
directory, it is better if you copy it without the .sh extension:
$ sudo cp /path/to/homestead.sh /usr/local/bin/homestead
$ sudo homestead create example.test
The above command will do the following:
-
Add
example.test
in your/etc/hosts
file -
Create the site's folder in your host system at
~/workspace/www/homestead
with the nameexample
-
Add an entry for
example.test
in yourHomestead.yml
file -
Reload and re-provision vagrant
$ sudo homestead create example.test dir_name
$ sudo homestead create example.test dir_name apache
$ sudo homestead destroy example.test
To delete a site with custom directory name:
$ sudo homestead destroy example.test dir_name