Automatically create new site on Homestead
Everything that you have to do when you add new project to your Homestead VM:
- create project's folder
- edit /etc/hosts
- edit Homestead.yaml file
- reload & provision vagrant box
- Download the code
- Make the file executable
chmod 755 addsite.sh
- Edit addsite.sh, update base path config
- Run in terminal where you can provide attributes directly:
addsite <project name> <folder relative path>
...or if you don't provide the attributes, it will ask you about each one.
################ UPDATE HERE ###########################
vagrantIp="192.168.10.10" # change it if you set different vagrant box ip address
baseVagrantPath="/home/vagrant/Code/" # mapped vagrant box folder path
baseProjectPath="/Users/zhou/public_html/" # local folder path
baseHomesteadFolder="/Users/zhou/.homestead" # homestead yaml file path
homesteadPath="/Users/zhou/public_html/Homestead" # homestead vagrant file path, where you usually run vagrant up & halt
################ UPDATE HERE ###########################
./addsite.sh homestead.app homestead/public # locate to your index.php file
Based on config above, the script process as below
- Add
192.168.10.10 homestead.app
to /etc/hosts - Add
map: /map: homestead.app to: /home/vagrant/Code/homestead/public/
toHomestead.yaml
file located at"/Users/zhou/.homestead"
- Cd to
/Users/zhou/public_html/Homestead
, and runvagrant reload --provision
That's it, your new homestead.app is all set.
This repo clone from https://github.com/raffw7912/homestead-add-site.